The problem with programming!
The alternate title for this article could be:
Why I dislike C++, C# and other languages ?
Let me start out by saying that I am a PowerBasic programmer. BASIC has been my primary language of choice and PowerBasic so far has been my favorite BASIC language. Now I used to like Visual Basic when it first came out, but that was primarily because of its ease of developing user interfaces. PowerBasic could learn something from the early years of Visual Basic. But despite PowerBasic not being on par with Visual Basic of old when it comes to UI development, in my opinion it is superior to Visual Basic when it comes to raw power of a compiler.
Why I dislike C++
BASIC has the advantage of being a more natural language and a cleaner syntax in my opinion. BASIC is easier to read. Yet if I were force to learn a variant of C, I would more likely opt for C rather than C++. Why ?
Modern languages have been overtaken by object oriented coding styles. Now I am not against using objects or classes, but in my opinion objects or classes should be treated like any other feature of a language, such as data types or code structures. Rather than “everything should be an object”, objects should be used only when some situation really warrants an object. User Interfaces (ie. Visual Basic) lent themselves to being defined as objects, so that is a good example, even though user interfaces can also be just as easily defined without a single line of object oriented code if we really wanted.
Objects add complexity, rather than decrease it. Combined with C++’s cryptic syntax, I just can’t even see how a modern C++ application is even readable. When I see C++ code, I find it so terse that I often don’t even know where to start. On the other hand, when I see good old fashion procedural style C code (non OOP), even though C is foreign to me I can still usually make some sense of it and port it to PowerBasic.
I tend to stick to the old adage of “keep it simple” and I like programming languages which lend to code which is simple and readable. One strange thing though which I have noticed about how I like to code is that while I try hard to shield myself (and others who use my tools) from the complexities of the Windows API (WIN32) , I am also drawn to low level coding. How often I use things like pointers in my powerbasic code and even my own GUI library (EZGUI) provides access to graphic data and some other data via pointers when it really warrants it. For example, EZGUI allows access to pixel data in DIB (device independent bitmaps) via pointers and I even encourage users to use this technique. Why ? Because it is very powerful and some things just can’t be done any better than via pointers. EZGUI also passes some data to Events via pointers. Now I provide simple subs/functions to access that data without actually having to write any code to use pointers directly, but still I use pointers in passing the data. Why ? Because it allows direct access when it may make sense to do so.
Now if object oriented programming was designed to shield programmers from common problems, it in my opinion has only added to the complexity of programmer, rather than shield programmers from common problems. Programmers should learn how to write both high level and low level code. If a programmer can’t handle something like a pointer, when it is really useful to use, then maybe they shouldn’t be programming. Pointers are not that hard to understand.
Another good example of how modern programming has gone too far is the view of things like GOTO. Even someone as experienced as Alexander Stepanov sees the value of something as simple as the GOTO command (still found in BASIC). What do people think the compiler actually generates when it compiles many of the modern logic commands of our modern languages ? Do we really think that a compiler never generates a machine language equivilent to GOTO ? Of course it does, so why can’t we use GOTO when it is warranted.
OOP programmers somehow get the idea that anything which is not written using objects or classes is spagetti code. That is totally wrong. Using a more procedural approach does not mean that code can’t be modular. The idea behind STL (standard template library) in C, C++ is basically the idea of writing a solid reusable library. A programming language does not have to impliment its own version of a standard library as objects and classes. They key is that the library is reusable and low level when it makes sense and high level when it makes sense. Modular design is vital in software development and I agree. Objects and classes are not. There may be times when objects really make sense, so yes use them. But a programming language should not be literally controlled by the object oriented approach. This is one reason why C++ or C# does not appeal to me (even though I recently purchased older versions of Microsoft C++ and C# just so I can at least experiment with them).
The result of todays programming languages, in my opinion, is software which is bloated, wastes valuable resources and is harder to maintain. Do you realize that a lagacy version of Windows (Windows 95) could run on as little as 32 megabytes of ram and run great, while Windows 7 can barely get by with 1 gigabyte of memory. Do you realize how much memory 1 gigabyte even is ? One megabyte is over one million ascii characters. Thats a lot of information. One gigabyte is a huge amount of space. Now of course some data requires huge amounts of memory, such as graphics, but the majority of an application is not graphics. It is simple data, even what is stored in user interfaces is often simple data.
Programming languages have become bloated too. Imagine how I felt when I downloaded and installed the latest Visual Studio only to find it required over two gigabytes of space to install. I can install PowerBasic 10 and it only needs about 20 megabytes of disk space. Why in the world does Visual Studio need two gigabytes ? Doesn’t anyone else see something wrong here ? If modern programming languages did not have intellesense, they would be totally unusable.
I recognize that one needs modular design, quality User Interface libraries and visual drag and drop environments to be able to design complex applications faster, but are we really producing better software today and are we really building software faster and better than before ? I have not been drawn to either C++ or C# simply because they confuse more than they help. I do not see simplificity in either. Just think, as a BASIC programmer, if something like C makes more sense to me than something like C++ or C##, then something is quite wrong.