October 21, 2022

The surprising success of the C programming language

 

There is some sort of mystery in the history of computing. In spite of many criticism, the C language was never abandoned but it was used over decades for creating all sorts of programs. To understand the success we have to focus first on some of possible alternatives.
Since the early 1980s the C language was known and many attempts were made to program in a different language. Notable examples are Basic, Pascal and recently Python. All these programming languages are promising to the newbie that it is possible to write software without much effort. Basic was the first widely used interpreted languages. First versions were oriented on line numbers, while later Basic interpreters like Omikron Basic and Visual basic provided the ability to create large projects with structured and even object oriented features.
The problem with basic language was, that it was never standardized. A program written in Qbasic can't be executed in visual basic. And both systems have the problem that the generated executable code is very slow. Many programming languages were invented over the years. Some very successful examples in the recent years are python and C#. In contrast to BASIC, Python is standardized, cross platform ready and has a huge amount of libraries. Similar to Basic it is used by non programmers for creating a prototype. Then the code is deleted but never reused again.
Parallel to the development of these alternative language, the C language has remained stable over the years. What is known as modern C is the same what was used in the late 1980s as C90 standard. It is a standardized compiled language which is used to create production software for the public.
Roughly spoken, Basic and python are toy languages even they are used by 99% of the programmers. In contrast, C is practical language because the code is written once and then improved over decades. The chance that newly written Basic code can't be executed after 5 years is high, while the future of C is more secure. Created C code in now will be uptodate after 10 years from now for sure.
The obvious difference between python and C is, that python is easier to read. Similar to Pascal It is a great language for academia, but it fails for writing operating systems or even normal software. Basically spoken,the programming world is divided into two groups: c programmers and non c programmers. The non c community is much larger. Most books, tutorials and written lines of code are created in non c languages like:
Python, Basic, PHP, Ruby, C# and Java
But, non of these projects are real projects in a sense that the code is executed on a computer. But the code is written once for testing purposes and then it gets archived somewhere
A look into one of the existing C tutorials is disappointing. There is no explanation how to program games, build a database program or create simple hello world apps. But the C books are explaining how the c compiler generates Assembly code without any practical purpose. C has replaced the former assembly language in the late 1980s. During that time it was normal to write code in assembly language. This was done for unix systems and home computers as well. C has replaced this programming technique.
The malloc command within the c language explains very well what the difference is between C and non c language. Malloc allows to ask for memory block from the operating system. The programmer can ask for 1 GB of memory and then the newly written code will nned such amount of RAM for runtime. Such kind of low level memory occupation is not possible with alternative language or at least it doesn't make much sense. Because most modern programming languages have a garbage collector. In Python for example, the user doesn't specify the datatype at all but he appends something in a list and the rest is delegated to the python interpreter.
[1] Bradley L. Jones: Sams Teach Yourself C in 21 Days, 2002
[2] O'Reilly Practical C Programming

No comments:

Post a Comment