October 26, 2023

Estimate the costs for Forth programming

 
The current computing mainstream works with a combination of C programs which are running on x86 CPU. From the perspective of Forth advocates the main critics towards this principle is, that x86 hardware has a huge transistor count and software written in C is not very efficient. Let us investigate how a potential alternative will look like.

The goal is to create Workstation desktop with stackmachines which are programmed in the Forth language. Current desktop ready operating systems like Linux and Windows have a space requirement on the hard drive of around 50 GB in total for all the libraries and programs which is equal to 1250 million lines of code. Because the existing C code base can't be executed on GA144 and similar Forth procssor there is a need to rewrite the entire operating system in Forth. The assumption is, that similar to C a single Forth programmer is able to write 10 lines of code per day. So it will take 342k man years until this project is done The only bottleneck is that such a project will cost a huge amount of money.

Let us go a step backward and describe what the underlying problem is. Existing operating systems are mostly written in C code. In addition the amount of code lines is very huge. There are many attempts available in the past to m odify the development process. Some kernels for operating systems were written in pascal and even assembly lanugage, while other projects were created as a lightweight single floppy disc operating systems. None of these alternative were successful. It seems that only the combination of the c programming language plus a huge amount of code line results into a successful operating system.

This makes it hard to decide for the Forth ecosystem which is operating with a different understanding of excellence. The typical forth project is of course realized in the Forth language and it has a low amount of codelines which is described as high efficiency coding. In contrast, existing operating systems are critized as bloatware.

Nevertheless there is a need to discuss possible future computer architectures because of the end of the moores law. Current x86 CPU have an overheating problem as a result of too many transistors on small space. So there is a need to build hardware with a lower footprint. In the past such cpu design was available for eample the Pentium I was equipped with only 3 million transistors. Unfurtunately, the Pentium I is too slow for modern requirements and putting more voltage to the device won't work.

What is a needed is a low transistor count CPU architecture which can run C programs. A c program is never executed on the baremetal but it is translated first into assembly language. The bottleneck is located in compiler design. Only if a compiler is available for a new CPU it is possible to port existing c code towards this platform. So we can say it is not about ARM cpu, Forth cpu or RISC cpu but what matters are compilers for these hardware.

A compiler is an intermediate between high level C code which is already there and a certain computer hardware which has to be invented from scratch. The existing x86 hardware itself is not very powerful, what makes this hardware relevant is the existence of powerful compiler toolchains which are converting existing software into assembly instructions.

Programming a compiler is perhaps the most advanced topic within software engineering. in contrast to a normal program which is a video game or a spreadhseet application, a compiler can transform one program into another program. it has much in common with an interpreter which is easier to realize but is much slower. A good example for an interpreter written in Assembly is the BASIC interpreter in the Commodore 64 written by Microsoft. This Basic interpreter is able to fetch the next statement in a program and executes it on the 6502 CPU. For doing so the high level BASIC command is converted into low level assembly instructions.

The main task of a compiler / interpreter is to communicate between human programmers who are not familiar with Asembly language and the CPU which accepts only assembly instructions. Without such an interpreter the computer can't execute BASIC programs.

It doesn't make sense to explain to the BASIC newbie that he should earn Assemlby if he likes to paint a graphics on the screen. The reason why the programmer prefers BASIC over assembly is, that it is easier to use and allows him to code the same program in a shorter amount of time. What is needed instead is a fast interpreter or even better a fast compiler which provides an additional layer between man and machine.

No comments:

Post a Comment