October 24, 2021

What is wrong with C?

 

Over the years, many programming languages have been invented. But which one is the best one? To answer the question the existing languages have to be ordered in categories. There are the following groups available: interpreted vs compiled languages, procedural vs object oriented languages, mainstream vs. uncommon languages. The idea is that a certain combination of these categories will result into a very well language.
Let us start with the famous Python language. Python is fore sure one of the most languages ever. In contrast to the earlier visual basic, python is accepted by everyone. No matter if the programmer preferes Linux or Windows, no matter if he is a beginner or an expert, python is loved by everyone. Python is located in the interpreted group and has object oriented features. This combination makes it very easy to create programs. Possible alternatives over Python is groovy, which has the same syntax but is less popular.
The main problem of python is that the performance is poor. It is not possible to write operating systems libraries or production ready code in this language. So possible second language is needed.
An interesting language to python is C++. C++ was used in the 1990s before scripted object oriented language were available. The main idea is to combine OOP features with a compiler. The problem with C++ is that the user has to use pointers all the time. Possible alternatives over C++ like D are promising to solve this issue but real programs written in D are using pointers also. A typical situation in these languages is that the user has to initialize an object on the heap, and then he has to send the pointer to this object to other objects. This programming style is very complicated to master, so C++ isn't the best language on earth.
From a more abstract perspective the question is how OOP features are related to compiled languages. It seems that OOP works fine for scripted language. In case of compiled language OOP is harder to realize. So a working hypothesis is, that compiled language should use OOP features at all. And this will lead to the very interesting old and new language C. C is a compiled language which has pointers but not OOP features. Writing code in C is different from writing code in Python. C is located on the low level and the user has to fulfill the needs of the machine. In exchange C provides a fast binary code which works great in a library.
The open question is if OOP features can be combined with a compiled language. Let us try to convince existing Python programmers to switch to the C++ language. Unfurtunately, this is impossible. Python programmers have no advantage if the code is compiled but it will make the edit compile run cycle slower. Also python programmer doesn't need to use user pointers so the C++ language doesn't make sense for him. The prediction is that C++ will struggle in replacing python. And that means, C++ struggles in become the number one high level language used for prototyping purposes.
In the second step the idea is to convince existing low level C programmers to use C++. The advantage of C++ over plain C is that C++ has olasses. Unfortunately, C programmers have no need for classes. The reason is that C programmers doesn't implement prototypes or writing hello world scripts, but c programmers are writing low level libraries and operating systems. That means C++ will fail to become the number one low level language. And this means, C++ can't become the number one in any category.
The logical consequence is that the attempt of combining a compiled language language with object oriented feature have failed. It is a dead end in programming language design in trying so. In general the categories are:
1. low level procedural languages which are compiled and very fast
2 high level object oriented language which are interpreted and slow
It is not possible to invent a language which fulfills both needs. Instead separate languages are needed for each purpose. Bascially spoken the following programming languages are outdated: Java (but groovy not), C++ (but C not), C#,
From a positive standpoint, C programmers will never switch to C++ and Python programmers will never switch to C++ as well. A simple look in the existing programs written in C and python as well will show that both programming styles are too powerful that any language in the world can provide an alternative.

No comments:

Post a Comment