Bringing Forth to the desktop

People who have this blog since a while, would recognize that in the subtext the Linux operating system was recommended for programming tasks. Right now, it is the most advanced piece of software I’m aware of it. But perhaps this decision can be improved if we are let the Forth language come in. The question right now is how Forth can be compared with Linux. The main idea behind Linux is, that software is everything and hardware can be ignored. The Linux kernel is implementing a complete operating system from scratch and ignoring existing BIOS drivers which are built-in every PC. But, after booting up a PC the system knows exactly what a network is, what a graphics card is and what a cpu scheduler is, even without booting the Linux kernel. All the information are stored in the BIOS, in the existing ROM chips on the hardware and even on the CPU itself.

Forth is a good choice because Forth is as default lowlevel and bare-bone oriented. That means, a typical Forth program contains of low amount of commands and if a Forth system was programmed right, it will use existing BIOS routines and doesn’t invent his own network system. The main difference between Linux and Forth is, that the Linux OS is documented quite well with lots of tutorial like the famous book of Andrew Tanenbaum, while around Forth there is no information available. Today, I’ve checked out Stackoverflow. Under the tag “Forth” they have under 200 questions right know. This can’t be called a huge community, it is more a niche.

The main idea behind Forth is a better balance between Hardware, software and operating system. Linux has the focus entirely on software, Forth is more hardware oriented. In theory the result is a more efficient overall system, which needs less power consumption and can be programmed easier. The drawback is, that in the now it is very complicated to write an OS in Forth, mainly because nobody has tried so before. The only bigger example is the iTV company of CHuck Moore which has developed a workstation. But the computer isn’t sold anymore and the iTV PC is not available in a computer museum so that nobody can reverse engineer the software.

In theory the famous SVIG (Silicon Valley Forth interest group) has the aim to promote the usage of Forth, but everybody who has read their printed publication or watched one of the youtube streams will recognize that they are doing exactly the same. SVIG doesn’t bring Forth into the mainstream, they make complicated things more complicated. So the problem is: where to start if the aim is to make things more transparent? Right now I see two potential starting points for teaching Forth to a mainstream audience. The first is to simulate a CPU in an electronics simulator. That means, every transistors is visualized and the user can see who 1000 transistors are forming a CPU. The other possibility is a qemu image, which is an operating system written in Forth, compared to the menuet-OS project. The aim is, that the user can boot up the system and run his own Forth software in it. This allows him to interact with the existing BIOS which is emulated by qemu too.

In contrast, I don’t think that existing Forth implementations like gforth or Forth derivatives like Factor are making so much sense. Because it is unclear what the advantage to existing software is. The main advantage of Forth is, that it can replace Linux, so there is a need to bare-bone programming directly on the hardware.

One aspect in Forth is important. The language isn’t faster then C. This might be surprise because most people are interested in efficient computers. But it is in reality not a big problem. The slowdown of Forth compared to a C program is not more then the factor 3. And this amount can be compensated by better hardware. If the aim is to speed up a Forth program, not a better compilation to existing x86 architecture is used, but instead a better CPU can used. For example a memristor which is a combination between DRAM memory and CPU.


A carefully dive into “Forth vs Linux” debate

Linux can be called the most advanced operating system right now. It is hacker friendly, is open source and is used on many servers and as a workstation. Sometimes, Linux is compared with netbsd, FreeBSD or SUN OS, because these systems were used early on workstations, but in general Linux is accepted as superior, mainly because of the size of the community and how fast changes are integrated into the kernel.

But, there is competitor in the shadow, called Forth. In theory, Forth can replace Linux. But it is unclear how exactly. Let us make things more easier and describe what Forth can do for a user in the mainstream. A computer can be booted with qemu, but qemu needs an operating system which is stored in the .img file. Some github projects are available which provide such a qemu image with Forth. The idea is similar to the retroforth project which was programmed for the Commodore 64, but only for the x86 PC.

The assumption which was teached by Linux is, that after the booting, the operating system must provide all the hardware drivers for example network, graphicscard, filesystem and so on. And that without the Linux kernel and the userland no additional program can be started. But is this assumption correct? Every computer has a BIOS as default. The BIOS provides the VESA standard which is able to paint lines on the screen. So in theory it is possible to run a PC without an operating system, or with a very small one, for example QNX which is much more compact than Linux. What if we program in Forth a small operating system which is utilizing existing BIOS routines for getting network access, videographics access and put sound to the speaker?

It is unclear right now, if this is possible but it would bypass the existing Linux ecosystem. It would feel more like the early MS-DOS which contains only the msdos.sys and file, but is programmed in Forth. And thanks Forth no complicated C compiler is needed. So the whole system would be a strip down version of Minix 2.

Suppose, a Forth microkernel is able to start high-level programs and schedule them. Suppose the system fits in under 500 kb and is more efficient than current Linux distributions. What can the user do with such a system, doesn’t he has to write Forth code? Yes, he must. It is not possible to execute Linux binary in Forth, so the user must write all the software from scratch. But, as far as i have seen in the Forth documentation it is able to extend the ANS Forth standard with object oriented features. And writing all the needed software is possible. On the first look, the Forth syntax is a bit complicated, but not more complicated then C++. But the main advantage is, that it will run efficient, especially on low power cpus.

The disadvantage is, that the user will loose most of today’s ecosystem: the Linux operating system, the C/C++ compiler, existing libraries for OpenGL access and most other features created by the Open Source movement like the Ubuntu ideology which has the goal to teach programming to beginners. In contrast, a software ecosystem made of Forth is much more mature. That means, Forth is the language of computer scientists

What is the idea? The idea is to create a compact operating system, which is faster than Linux and takes less resources than Linux..Such an operating system is not programmed in Assembly language like the menuet-os example, but in High-level Forth. That means, in Forth is assembly language integrated for setting the BIOS Vesa mode, but then the user can use Forth high-level commands to put lines on the screen. It is unclear, how to program such a Forth OS, but in theory it would make sense.

The most dominant problem is perhaps, that existing software written in C would no longer run in Forth. It is not possible to convert C sourcecode into Forth. Only the opposite direction is possible, but there is no github with Forth sourcecode available. That means, the project would start from scratch and write everything new. As far as i can see at Stackoverflow and on github, there is no large community available which is interested in such a project. Most programmers are fully stretched with Windows, Mac and Linux, they didn’t see a need for Forth. And the programmers who are familiar with Forth are also not interested because it is to easy for them to write a QNX clone in Forth. It is something which doesn’t bring the Forth movement forward.

Forth is the wrong way, because it makes no problems

The Forth programming language is superior to all other computer architects. The programs runs better and the hardware is more efficient. But for teaching purposes this is not a wishful state. Students learn better if the underlying system isn’t working very well. The UNIX operating system produces a lot of trouble, and this is the reason why it is the better teaching tool. Apart from a datastack and a returnstack UNIX has much more to offer, for example a POSIX API and a high level programming language, called C.


The paper is copyright protected. That means, it is not allowed to redistribute it over the internet or in Academic social networks. To get access to the fulltext, the user must proof, that he has reasonable knowledge about Artificial Intelligence.

1. Who has invented the perceptron in 1957?
a) Frank Rosenblatt b) Richard Feynman c) Dennis Ritchie

2. Which programming language is used heavily for Aimbot programming?
a) PHP b) LaTeX c) AutoIt

3. Who is the inventor of the git-version control system?
a) Linus Torvalds b) Bill Gates c) Steven M. LaValle

4. What is PDDL?
a) computergame b) operating system c) symbolic planner

5. Who is the inventor of BEAM robotics?
a) Mark Tilden b) Sebastian Thrun c) Marvin Minsky

The passphrase gets formed by the correct answers in the quiz. For example, if the choice is question1=c, question2=a, 3=a, 4=a, 5=b the following bash command in the Linux operating system is used for decrypting the paper:

gpg --passphrase 1c2a3a4a5b paper.txt.asc

Here comes the fulltext of the paper.



Programming in Forth – the right way

In the picture above we see an example of using Forth. The screenshot was taken from a japanese Forth forum on the internet. The people there are encouraging each other to learn Forth and everybody is welcome who is interested in writing easy and not so easy programs. The URL of the forum is and the guidelines are very strict in relationship to the japanese language. That means, it is not allowed to posting something in English.

Why Forth makes sense on Stackoverflow

The number of Forth-related questions on Stackoverflow is small. Around 180 are there. Not 180k, but only 0.18k. Today’s programmers have other needs then playing around with the stack or write factorized sourcecode. The major Forth-related online forum is the usenetgroup “comp.lang.forth” which has a high traffic. But for the future it makes sense to push the Forth ideology into Stackoverflow. There are many reasons. At first, Stackoverflow has a unique capabilities of posting images. If the question is more complicated a figure may help the understanding. The second, more important reason is, that Forth is not really about the programming language. Forth was not invented for writing real software in it. It is some kind meta-language which helps to learn other languages. For example, if a C++ programmer wants to write better code. Than he should take a look at forth, because the code examples there have a high-quality. It is clean, efficient code. And if a compiler-designer want’s to improve the Java virtual machine, then at look at Forth helps a lot. Without no doubt, the Stackoverflow community has the largest number of programmers and potential programmers worldwide. So it is the natural place for discussion concatenative programming language.

Sometimes, Forth is described as a lowlevel, assembly like programming language. But in reality, Forth is focussed not on computers but on people. It is a learning tool for teaching cpu-architecture and software-development. The best platform for running forth is not the GA144 cpu or the Intel CPU, the best platform is a computer course at the university. The idea is to use Forth as a dry language inside a pen&paper computer. The main advantage is, that only Forth is minimalistic per default. A Forth CPU is the smallest form of a cpu, a Forth compiler is the smallest piece of software and so on. Holding Forth outside of todays programmer community with the reference, that the language is obsolete makes no sense. Yes, Forth is outdated, and this makes it attractive for teaching. Possible alternatives to Forth are not C++ or Java, but the teaching languages PL/0 (Wirth) and the teaching cpu MMIX (Knuth).

New paper in preparation

I’m currently writing a new paper about the Forth programming language, a small example is given in the image above. The reason is, that the language Forth is very interesting and until now only few papers where published about the topic. The idea is not to propagate the Forth language itself, but to write a Simulator like the “little man computer” to run Forth programs in debug mode. That may be a bit surprising, because normal programming language are used for something meaningful. For example, C++ can be used to write a database application. So the natural idea is to use Forth for programming a hello world application or alternative make a Forth based hardware. But both is not the intention of my paper. Making a Forth chip in FPGA hardware is way to complicated for amateurs, and programming a longer software with Forth is also a pain. So the normal result is, to not using Forth for something useful and research other programming languages like Java, Python or whetever. But there is an alternative. The idea is not to program in Forth, but in C++. The C++ program is some kind of game in which a Forth Virtual machine is executed. The idea is heavily used in the minecraft community who are using the building blocks to build a 8 bit cpu and playing around with it. The interesting aspect it, that it is no longer a Forth implementation but it is more a C++ project in which Forth is part of.

The background is, that Forth is way more useful than using it only as a language. Forth can be understand on a purely theoretical base. That means, without programming the language or without building real CPUs. But I do not want to reveal to much of the coming paper. In contrast to my previous paper about Forth it will be written in English and it will have lots of figures. Perhaps this will increase the audience.