:r4 web site

View on GitHub

:r4 programing language


:r4 is a language created in 2005, based on ColorForth. Since all Forths are minimalistic, :r4 does not need complex mechanisms of abstraction, in fact the only mechanism of abstraction is the address. Forth isn’t as popular these days, but curiously does not die. Every Forth programmer knows why.


The idea is simple:

* Any number in the source code goes directly to the data stack.
* Any address of a word goes to the stack too.
* Any word (characters separate by spaces) searches in the dictionary,
  +	If it is found, execute the word.
  +	Else is an error, stop the compilation!!

Unlike ColorForth, the meaning of words is defined by prefixes. The most important prefix is ' (adressof). If word executes a word, then 'word is the address of the word. This address prefix is a powerful abstraction, many languages try to avoid this, but here we recommend its use.

To create a program, you need to define words that express an algorithm that tries to solve the problem that is being solved.

A program has two types of words: actions and data (time and space). To define an action :r4 uses the prefix : and to define data the prefix #

:thiswordisanaction 1 2 3 + * ;

#thisisdata 33

When you define a word, you can use previously defined words, or the current word for recursive words.

When you start a program, the dictionary has the following basic definitions:

Main Dictionary

The main dictionary has a basic interaction with the OS, 12 words, which is very basic. This approach has some advantages over trying to recreate all the API calls.

The cons is not having full access to hardware, for now!, we can modify this at any moment.

Words for SOUND, PRINTER, JOYSTICK and WEB has a definition for particular needs, but the idea is to avoid this and at some point, recreate in :r4, the graphics words are already recreate for the actual compiler.

Keep it simple, this is the main path, but simple is not easy, is a search in the world of problem for extract or ideate a correct and basic solution.

A more advanced introduction


More about Registers

Current development

The current development in computers is dominated by certain ideas that in my opinion are wrong.

The idea of using complex structures to simplify development only makes the problem worse. In addition to hiding certain parts of the problem that should be exposed to see the solution correctly.

The idea of defensive programming by calling a lawyer and making it clear that it can be done and not done, even before writing a single calculation, then now instead of having an algorithm, we have an algorithm and a lawyer.

Many good programming practices are wrong, since you try to find a generality in the development and the systems solve a unique problem, not a different set of problems. Charles Moore say, real programs execute in real computers.

Basic Library


The Basics

The Main Loop


Vectors Graphics






Data Structures




3d Math



Memory Data Base

Basic Shooter


The :r4 compiler make two files in r4asm/ folder, code.asm and data.asm and then this is compile when call FASM.


Post Tokenizer

Generate Code

Profiler Code


Text Editor

Vector Editor

Bitmap Editor

Icon Editor