RETRO is a modern, pragmatic Forth drawing influences from many sources. It's clean, elegant, tiny, easy to grasp, and adaptable to many tasks.
It's not a traditional Forth. Drawing influence from colorForth, it uses prefixes to guide the compiler. From Joy and Factor, it uses quotations (anonymous, nestable functions) and combinators (functions that operate on functions) for much of the stack and flow control. It also adds vocabularies for working with strings, arrays, and other data types.
The source and documentation are distributed under the ISC license.
RETRO has been built and used on many systems including DOS, Windows, Linux, FreeBSD, NetBSD, Haiku, macOS, and iOS. Tested host CPU architectures include x86 (16 and 32 bit), x86-64, ARM, and PowerPC.
The standard binaries are entirely self contained and need only standard system libraries to run.
In addition, RETRO includes an interpreter that can make direct use of system calls to avoid even libc on FreeBSD, Linux, and macOS (x86, x86-64).
RETRO is small, in both source and binaries.
A minimal C implementation of the VM is 641 lines, including commentary. The full implementation is 1,802 lines. On FreeBSD x86-64, the executable sizes range from 48KiB to 84KiB.
The language itself is written in assembly for the virtual machine and Forth, taking 1,232 lines and 35KiB. (The 35KiB image size is included in the binary as they embed a copy of the image.)
Sources in RETRO are in a literate format, using Markdown-style fenced code blocks.
~~~Define a word (function) that removes vowels from a string:
[ 'Welcome 'To 'Retro ] set:make [ s:put sp ] set:for-each
~~~And test it:
:s:darken (s-) [ c:-vowel? ] s:filter ;
~~~Thanks for taking a look at RETRO!
This is a quick and dirty way to find prime numbers in a set.
~~~And a test:
#2 'NextPrime var<n>
[ @NextPrime dup-pair eq?
[ drop-pair TRUE ]
[ mod n:-zero? ] choose ] set:filter ;
dup fetch [ extract &NextPrime v:inc ] times ;
here #7000 , #2 #7002 [ dup , n:inc ] times drop ;
create-set get-primes [ n:put sp ] set:for-each