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.

Forth is here to stay

Some while ago i discovered the Forth programming language. The first posting in the blog here is from year 2016. At the beginning Forth makes absolutely no sense, it is so different from a normal programming language and the proposed hardware architecture is also not mainstream compatible. After some introductional paper I get very slowly an understand of Forth. At first, it is not possible to use Forth as an alternative to existing C programming languages. The reason is, that there are no software in Forth available and a hello world program runs in Forth at least 10x slower than with a C compiler. But, Forth main advantage is, that it can be used in computer teaching. If someone wants to know, how a cpu works, and what a compiler is, than Forth is his friend. I would compare Forth not with C but with teaching only languages like PL/0 or PASCAL. Forth has a very clean syntax which is comparable to Assembly.

The best way of formatting sourcecode is given by Instead of what is used in most books about Forth, the above URL writes the sourcecode from top to down. And a Forth word is equal to an assembly label.

The interesting aspect is here again, that the projects done with Forth are pointless. Writing a program which calculates the greatest divisor can be done in C more easily, and the FPGA software is not able to boot the Linux kernel. Again, Forth was never created to make real processor with it, but it is comparable to the MMIX cpu from Donald E. Knuth. His cpu was also not designed to work as a physical cpu for run real software, but as a tool to explain how a cpu works. In this specific domain of teaching computer science, Forth is top of the pops. That means, there is no better alternative out there. Forth is minimal and powerful at the same time.

Whats next?

The youtube video in the beginning of this blogpost shows a running Forth simulator. It was written not in Forth but in normal C++ together with SFML. This simulator can be extended. It has today many bugs and the layout is not really good. I think, it would make sense to improve the simulator a bit. Not because he can run a program faster than the GCC compiler can, but because of the opposite. The above simulator has currently a speed with around 2 instructions per second. The reason is, that the game loop waits in every iteration for 500 msec. A faster execution makes no sense, because the user want’s to see the program flow. I think, the future of the simulator is not a higher performance, but more visual feedback. The idea is to explain the stackmachine for newbies. The best way to do so, is to understand the simulator as a game. It uses SFML for drawing a window, has a dedicated gameloop and can be used interactively. For example, the user can move the instruction pointer with cursor keypress.

Another problem with the simulator is, that it misses the hardware details. The so called “execution unit” is realized usually with AND, OR, NOT gates. The number of a simple Forth processor is high. The Mup21 cpu has for example 7000 transistors, while the MSL16 (another Forth chips) needs around 175 CLBs. (A CLB is the smallest unit in an FPGA.) In theory, the simulator has to be extended with a zoom function to show all the single transistors. But that is a bit difficult to implement.

# Assembly
  mov ax,bx   ; do something
  mov bx,ax   ; do something
  jnz show
  mov 0,ax
  mov 2,bx

# Forth
: main
  5 1
  .    \ print
: show
  temp @  \ fetch variable
  .       \ print

In the above example listing, Forth is formatted in the same way, Assembly is formatted usually. Not from left to right, but from topdown. Assembly and Forth have much in common. Forth can be seen as some kind of stackmachine assembly language with an educational purpose.

Why Forth?

There are many definitions out there was Forth is. Instead of explaining the language itself, I want to describe Forth as an education tool for understanding assembly language. Let us investigate first, what the mainstream way is to become familiar with the AMD64 architecture. Under the URL there is the official “AMD64 Architecture Programmer’s Manual Volume 1 ..5” which has each around 600 pages. A look into the manual shows us, that it is very complicated. The next option is to read not the reference manual itself, but some of the “Assembly language tuturials” which are explaining how to use NASM for compiling a hello world program in assembly. But after a while the above cited reference manual will also be needed.

The good news is, that there is an alternative to this. It is called Forth, and the introduction is done with the Jonesforth tutorial: Jonesforth is some kind of tutorial of how to write a Forth system from scratch. The basic idea is to implement in assembly language some high-level macros like “dup” and “NEXT”. That means, after calling NEXT around 3 assembly commands are executed on the PC. The overall system is a Forth system.

From a user perspective, it is not possible to do any useful task with Forth, which can’t be done with normal C programming or normal assembly language too. The advantage of the Forth way of life is, that the language supports the learning of the advanced programmer. I would suggest that it is possible to become familiar with AMD64 in a shorter timeframe, if the idea is to learn Forth and not Assembly. The most important aspect of Forth is, that it is ignoring completly existing architecture. That means, in studing all the 16 registers of current AMD64 architecture and become familiar with the around 1200 opcodes, the programmer learns only the 20 Forth commands and this knowledge can be used to understand any CPU out there. If this positive vision is reachable in reality is unclear, but the idea behind Forth is to do so.

But in one point I want to critize Jonesforth and most other projects. They are to focussed on programming in reality. The goal seems to be to get sourcecode running on real machines. I would go a step back and implement the Forth system not on hardware but on a pen&paper computer, called pushdown automaton. That means, to “boot” Forth not an x86 or on a microcontroller but as a game in Minecraft and SFML. What do i mean with it? The idea is, to draw a pushdown automaton on the screen. This can be called “Animation of a running computer”. It means to visualize the register, or in the case of Forth the stack. And everything what is not in the image visible is simply not existing. That means, there is no hidden Forth interpreter in the background, which takes a word and searches in the dictionary, but there is only the pushdown automaton as a graphical notation.

The reason is, that using Forth for real programs is not the intention. Instead, Forth is a “learning only” computersystem. It makes sense, to use it in a dry run without booting a real microcontroller or a real PC.