August 14, 2021

Some reasons why Forth felt out of fashion

 

In the late 1980s the Forth programming language was discussed in lots of magazines as a valuable alternative over C and assembly language. With the advent of the PC the situation changed drastically and Forth has became the most esoteric programming language ever. It is located in the now on the last position in the TIOBE index which means that user share is low.
There are many reasons available why Forth went into a minority language. The strength of Forth is that the sourcecode very small. This was important for homecomputers in the 1980s in which the amount of RAM was 64 kb and less. Today's RAM has become much larger and nobdy care if a program needs 20 kb or 200 kb in the main memory. A second advantage of Forth is it is working without batch compilation but a Forth system provides a real time compiler. That means, the user hasn't wait until the compiler has created the binary file but after entering the code into the editor it can be executed immediately.
Unfortunately, this advantage is also no big thing. Modern compilers are fast enough and in cast of doubt the user can take an interpreted language so he won't confronted with long compile runtime. A third advantage which speaks for Forth is the ability to get executed on minimalistic cpu which have only a little amount of registers. The reason is, that Forth works fine with only two simple stacks and no further memory cells on the cpu are needed. This advantage has also become not needed anymore, because all the CPUs were improved with additional registers so that they can run high level code generated by c compilers.
Apart from the mentioned advantages, Forth has some built in disadvantages which are avaialble. For example the programmer has to think like a push down automaton, he has to factor code into small subroutines, he is not allowed to use variables and the runtime speed of Forth is lower than the output of a modern c compiler.
As a result, all the advantages of Forth are no longer relevant but the disadvantages haven't disappear. It is not very complicated to estimate that the average programmer has lost it's enthusiasm for the Forth language and prefers more mainstream alternatives like C, Java, perl or GNU bash scripting. The situation today is, that apart from a small amount of demo programs for printing out primenumbers to the screen no larger software was written in Forth and the language is ignored by the world.
In general, Forth is the natural opponent to the C language. the c language has become very popular. This wasn't expected in the 1980s. During the 1980s, C was only one language and many. It stands in contrast to pascal, Simula and Basic. Compiing a C program on an 8bit homecomputer was an advanced operation. With the advent of the modern PC which includes graphical operating systems, hardrives and fast processors the situation has changed drastically. C has become the defacto standard for software writing. And all the important programs are implemented in this language first. Some years ago it was estimated that 75% of a Linux distribution was written in C. And the chance is high that for MacOS and Windows operating system the same ratio is valid.
Forth can be seen as an alternative world in which C never became popular. From a Forth perspective, the c language is using too much energy for the CPU and the code is bloated which results into lots of bugs. A typical Forth program will run on CPU which needs 5 milliwatt and is stored in 100 kb of ROM, while a typical C program gets executed on a CPU whic consumes 200 Watt and needs 8 GB of RAM.

No comments:

Post a Comment