What is it with the love affair with C ?
I was just reading a blog today with an article about what the next big programming language should be. What gets me though is how often those who ponder a better programming language use C (or C++) as the basis or foundation of what the next language should be. My question is why this love affair with C++ ?
As a long time BASIC programmer, I can understand why some may have negative views of BASIC, since they often equate BASIC with the old interpreters of old from the 80’s rather than the new generation of Basic compilers. What few seem to appreciate is that, BASIC has grown, even borrowing from other languages like Pascal or C, but using its own style of syntax. Why is the BASIC syntax so important ?
Because it removes the cryptic syntax found in most programming languages today (like C++ or Java) and replaces it with something more akin to the language we speak. I don’t know why programmers are often drawn to the cryptic rather than the simple. Personally, I find even good old assembler easier to understand than C++.
So why is syntax so important ?
Two problems plague all software. First is code readability. Most software eventually has to be updated and things added. The easier it is to be able to read source code, the faster and easier it will be to add new code to it. Now I will say though that good modular design is a must, no matter what language ones uses, so even BASIC code can be a mess if not written correctly. But when written using good modular design, BASIC source code can be so easy to read that a programmer can write something and then come back to it a couple years later and more easily make sense of it. The second problem is debugging. Again the easier it is to read source code, it makes it easier to find the errors in the code.
I am sure plenty who read this article will likely say, “but you can’t do the things I do with a BASIC language, like you can with C++”. While not all BASIC’s are created equal, I use PowerBasic and it has many power features which rival any C++ compiler in my opinion. To be honest though, PowerBasic is more of a coders language than a visual language. But when it comes to coding, you would be surprised at the things you can do with it.
Two areas where I really find PowerBasic to be just right for me are with strings and pointers. PowerBasics unique use of the Windows OLE engine for handling variable length strings is just downright perfect for many. You can work with variable length strings just like you did using old time Basics. No need to worry about defining an array of characters or some other technique. No need to worry about garbage collection. The compiler handles it all. You just use strings like they were meant to be used, but they can now be huge in size. Now add to this the fantastic selection of string functions PowerBasic provides and you have a powerful tool for handling large amounts of text with excellent performance. The second area which is a favorite is pointers. PowerBasics implimentation of pointers rivals anything you would find with C. I use pointers a lot. PowerBasic provides multiple syntaxes for handling pointers in different ways, so there are many options for solving problems while providing clean readable code. PowerBasic can even let you define an array into a block of memory (DIM AT an address) so the array looks like a normal array in code, but it actually is a pointer to a block of memory from something else. For example I could have a string variable and put any data I want into it and then get the address of the string and Dimension a numeric array inside that string. When you add PowerBasics rich set of data types with the use of pointers some really amazing things can be done.
In the old days, using the Windows API (WIN32) was too hard for many programmers, so Microsoft moved on to alternatives like MFC, ATL, etc. The interesting thing I have found as a WIN32 programmer is that the Windows API is not as confusing as you would think when you see an app written using PowerBasic syntax rather than C. Because BASIC is simpler in syntax and easier to read, API source code actually makes a lot more sense. True the Windows API is not easy to learn, but using PowerBasic it is a lot easier to learn and use than using C.
Now consider this. The Windows API documentation is all written with examples in C or C++ and not BASIC. PowerBasic programmers have had to spend time translating most of this info into Basic source code. Yet when you see the PowerBasic version side by side with the C version, interestingly the PowerBasic version makes a lot more sense. Someone who never dabbled with the Windows API would likely be able to make sense of the PowerBasic version quicker than the C version, at least in my opinion I believe so.
We don’t need more cryptic programming languages today. What we need is more languages which follow the rule of “keep it simple” like Basic has done. Code should be more readble, not less. Add to this a compiler like PowerBasic which produces fast (and small) executables which rival anything you can build with a C compiler and you have a powerful combination.
For more info about PowerBasic check out their web site: http://powerbasic.com