Get the latest tech news
Bootstrapping a Forth in 40 lines of Lua code
Quick index: Author: Eduardo Ochs eduardoochs@gmail.com http://anggtwu.net/ http://www.lua.org/gems/ http://www.lua.org/gems/selected.html Version: 2008feb17 Listings: http://anggtwu.net/miniforth/miniforth5.lua http://anggtwu.net/miniforth/miniforth5.out Preprint version: http://anggtwu.net/miniforth/miniforth-article.pdf Abstract: The core of a conventional Forth system is composed of two main programs: an outer interpreter, that interprets textual scripts, and an inner interpreter, that runs bytecodes; the outer interpreter switches between an “immediate mode”, where words as executed as soon as they are read, and a “compile mode”, where the words being read are assembled into bytecodes to define new words. In Forth all variables are accessible from all parts of the system.
Some of the reasons for that popularity were easy to quantify: compactness of programs, speed, proximity to machine code, simplicity of the core of the language - i.e., of the inner and the outer interpreters. None of these things matter so much anymore: computers got bigger and faster, their assembly languages became much more complex, and we've learned to take for granted several concepts and facilities - malloc and free, high-level data structures, BNF - and now we feel that it is "simpler" to send characters through stdout than poking bytes at the video memory. My personal impression is that Forth's main points were not the ones that I listed at the beginning of this section, and that I said that were easy to quantify; rather, what was most important was that nothing was hidden, there were no complex data structures around with “don't-look-at-this” parts (think on garbage collection in Lua, for example, and Lua's tables - beginners need to be convinced to see these things abstractly, as the concrete details of the implementation are hard), and everything- code, data, dictionaries, stacks - were just linear sequences of bytes, that could be read and modified directly if we wished to.
Or read this on Hacker News