4tH isn't the only Forth compiler that runs on several systems. However, 4tH takes portability a whole step further. Some C-based Forth compilers need a special C-compiler in order to compile. 4tH doesn't. It has been compiled using Turbo C, Turbo C++, LCC, DJGPP, GCC, XL C and a bunch of other compilers we probably don't want to know about.
4tH runs on most Operating Systems, including MS-DOS, MS-Windows (both 16 bit and 32 bit), Linux, Coherent, AIX, SunOS, BOS, BOS-X, BSD, Apple OS/X, BeOS, RISC-OS, etc. A full 4tH compiler (including VM, RPN calculator, editor, C-source generators) has a typical footprint between 50K and 100K (depending on compiler, optimizations and OS).
|At the left, 4tH running under Windows95 using VMWare. Top right, 4tH running under DOS 5.0 using DOSEmu. Bottom right, 4tH running under native Linux 2.2.14|
The obvious advantage is that you don't need CygWin or other emulation layers in order to compile or run 4tH. It is a native application by any standard. Consequently, 4tH has been ported to other environments or compilers we never planned for, usually without any or just minor modifications.
But 4tH takes portability even a step further. It is a bytecode compiler, like Java or Perl. The bytecode can be saved and run without any need for the original source. Bytecode programs are extremely small, e.g. a 'uuencode' implementation only takes a few hundred bytes, a full-featured block editor a few kilobytes. These bytecode programs are saved in a compressed, architecture independant format, so a 4tH program developed under Linux can easily run under Windows XP or DOS.
|4tH on the Zaurus
(Courtesy Wim Slangewal)
Since 4tH cannot be crashed (contrary to many other Forth compilers) it is extremely well suited for vulnerable environments. Another plus is that 4tH has a very small footprint. The Zaurus offered excellent support for development under Linux, so the first guy who popped up with a Zaurus was willing to give it a go.
|4tH on the Raspberry Pi|
Compiling 4tH was a breeze, no trouble at all. However, since the display on a Zaurus is quite small, we decided to make a few tiny modifications. The block editor has 64 screens of 8 lines of 32 characters and the main menu was compressed. 4tH now looks like it was made for the Zaurus and those changes are incorporated in 4tH. The current port of 4tH for the Ben Nanonote uses the very same code, since it has a tiny screen as well.
Our goal is following Linux wherever it goes, from the tiniest environment to the biggest environment. And even beyond: if there is a full fledged C compiler, you should be able to run 4tH natively there. Our ports to Coherent and the Raspberry Pi prove that.
4tH also successfully survived the move from a 32-bit environment to a 64-bit environment, taking full advantage of the increased word-size. New implementations of well-known algorithms were added for that, floating point routines were improved and an already existing fixed point library was expanded with several high-speed transcendental functions.
(Read this page in Serbian or Armenian)