June 05, 2019

Programming is equal to using a library


A common misconception is to separate between different programming languages like Pascal, C or C#. In reality, nobody cares if a statement should close with a semicolon or with a point which is used in Pascal for ending a program. The real difference between the language is hidden in the library. Let us take a look into the C definition. No, I'm not talking about the book about the C language itself, I'm talking about the C standard library. This is what programmers are using in reality.
According to Wikipedia, the C library https://en.wikipedia.org/wiki/C_standard_library contains of many useful functions. In the math.h library well known mathematical functions are realized like sinus, cosinus, log, random number generator and also the floating point calculation is there. Thanks to the stdio.h library, the user can open a file, close a file, Read a single character, write a string, seek in the file. The next very powerful library is string.h. This allows the programmer to append a string, search for a char in a string, get the length of the string and converts integer to a string. Also important is the threads.h library which allows the user to start different tasks at the same time, check which tasks get started and ends a certain task. What have all these libraries to do with the C programming language itself? Right, nothing. They are extension to the C language and make programming very easily.
What a programmer is doing in reality isn't think in categories of the C language definition but he is using existing library to create new programs. A simple example would be to write a calculator with the math.h library and save the result to a file with the stdio.h library.
What would happen with the C ecosystem if the user is not allowed to use the C standard library? It would become much harder to a write software. Even an experience programmer would struggle to write a simple calculator, because he has no plan how to realize the cosinus function from scratch.
The same powerful concept of introducing a library is available in other language likes C#. C# has the advantage over plain C that extra library for GUI creation are available. Again, the power comes not from C# itself, but out of the underlying .net GUI tools. What would happen if are playing the “library usage is forbidden” game? The user has to invent all the libraries by its own. He has to write it's own mathematical routines, program it's own operating system and draws the pixel by hand to the screen. As a result C and C# would become a beginner unfriendly language.
https://en.wikipedia.org/wiki/Category:Computer_libraries provides a long list of existing library. The interesting point is, that that any programming language has it's libraries. The concept is so powerful that nobody can avoid to using a library. Even the factorcode programing language (A forth dialect) comes with an extensiveness library. And if the aim is to create large scale applications and complicated games more libraries are needed. Let us take a look into the list of computer libraries to understand what programming is about. It is about audio libraries, gstreamer like libraries, concurrent programming, all sorts of graphics libraries, text rendering, widgets, multimedia frameworks, mathematical tasks, GUI toolkits, astrophysics problems, game engines, database components and many more libraries. The list is endless. It seems that programmer in general no matter if they are Java, Python, C, or C# programmer have a large demand for existing libraries. This allows them to code their software more efficient. And the trend is, that each year new libraries are added which are more powerful. The best example is the node.js framework which is not only a javascript based programming language but at foremost a list of Javascript libraries for doing all sorts of Internet related tasks.
Another point is important: a programming language becomes easier if the amount of libraries is higher. If the user has only the choice between 10k libraries he finds it hard to write a hello world program, but if the language has access to 100k libraries (for example in Python), than the example code in Rosettacode for showing the hello world message to the screen looks much easier. Especially the Python programming language shows the trend. Python is not a new programming language, Python is at formost a library wrapper to getting access to all the existing C/C++ libraries. And a future version of Python has also access to Java and PHP libraries as well. It is a paradox situation that the amount of documentation around these libraries is huge. A single C library contains of at least 100 functions and will take around 500 pages in us-letter. But it seems, that the programmer love these documents, because it helps them to become more productive.
Learning Forth
Suppose somebody would like to program a C program without using an existing library? Sure, it's possible he has to write the needed subroutines for it's own. Sometimes such a question was asked at Stackoverflow and in most cases it's possible. If this attempt is combined with the idea not to use the C syntax but a stackoriented language like Forth, the typical Forth programming style is the result.
Forth contains of two concepts. The first idea is not to use an existing library. That means, a dialect like Factorcode is the opposite of Forth. And the second idea is, not to use the normal C syntax but a simpler to realize stackbased syntax.