Forth is a stack-based concatenative programming language created by [[Chuck Moore]] in [[1970]]. # Notability Forth is a loose collection of rules and languages which winds its way through important historical moments without ever really becoming mainstream - at least not in a way that most people would recognize. Along with [[Lisp]] and [[Algol]], it is among the few programming language progenitors to established its own unique paradigm. It was finally standardized in [1994]. Its most notable descendant is probably the ubiquitous [[PDF]]. ## Uses - Philae Lander on the Rosetta comet mission - many[^1] other spacecraft[^2] - formerly used as the control software for Apple devices, such as battery management systems in laptops ## Implementations Arguably there are more Forth implementations than Forth programmers. Originally [[Chuck Moore]] didn't want programmers to use a single implementation and instead encouraged people to build their own. ### Software Probably innumerable software implementations, particularly as it was encouraged to build a Forth system from scratch. - 1130 Forth[^5] - jsForth - https://brendanator.github.io/jsForth/ - cmForth - STOIC ([[1970s]]-era FORTH variant) - https://en.wikipedia.org/wiki/STOIC - [[ColorFORTH]] - [[PC32 Forth]] (a [[ColorFORTH]] variant) - GDForth (an async FORTH for [[Godot]] by [sakiamu](https://cohost.org/sakiamu/tagged/forth)) - https://github.com/yumaikas/GDForth - MAR96[^7] (with preemptive multitasking and interrupt handling) - MicroForth[^6] (for the RCA 1802 8-bit CPU) ### Hardware - [[GreenArrays]][^3] - [RTX2010](https://en.wikipedia.org/wiki/RTX2010) - FRISC[^4] ## Descendants Forth has inspired many languages that came after. - [[Postscript]] & [[PDF]] - [[Factor]] - https://factorcode.org/ - [[blacklight]] - [[Rebol]] - [[Forsp]] ### IPS Interpreter for Process Structures (IPS), developed for satellites and other space missions. - Karl Meinzer, [IPS - High Level Programming of Small Systems](https://web.archive.org/web/20201112021517/https://www.jrmiller.demon.co.uk/products/ipsbk.html) `ISBN 0-9530507-0-X` (1997) **PDF at link** - Citation: https://search.worldcat.org/title/44831923 (2nd edition, 1997) - Citation: https://search.worldcat.org/title/1533642339 (3rd edition, 2019) - Store: https://www.amazon.co.uk/dp/1096992159 (3rd edition) - Karl Meinzer, [Byte Magazine: IPS, An Unorthodox High Level Language](https://archive.org/details/byte-magazine-1979-01/page/n147/mode/2up) p146-159 (1979) - Contains high level diagrams and a description of the language with some example code - [AMSAT-BDA: IPS Project Home Page](http://www.amsat-bda.org/IPS_Home.html) # Examples ```forth create a char a , char b , char c , create b char A , char B , char C , create c char 1 , char 2 , char 3 , : main 3 0 do cr a i cells + @ emit b i cells + @ emit c i cells + @ emit loop cr ; ``` # Resources ## Documentation - Chuck Moore, "*Forth, a New Way to Program a Minicomputer*" (1974) - E.D. Rather & C.H. Moore, [Forth - An Application-oriented Language](https://library.nrao.edu/public/memos/comp/CDIR_11.pdf) - For the Honeywell 316 computer ## Further Reading - Dave Gauer, [Ratfactor: Forth: The programming language that writes itself: The Web Page](https://ratfactor.com/forth/the_programming_language_that_writes_itself.html) (2023-2024) - Dave Gauer, [Ratfactor: Forth: The programming language that writes itself](https://ratfactor.com/forth/forth_talk_2023.html) (2023) **slides** - Attila Baksa, András Balázs, Zoltán Pálos, Péter Spányi, Sándor Szalai, and László Várhalmi, [Software on a Comet](https://sci-hub.se/10.1109/ms.2016.40) (2016) - This article may be inaccurate about the details, needs verification - Jay Melvin, [Demise of the Metacompiler in cmForth](https://www.pdf-archive.com/2015/01/10/cmforth/) (1989?) - Related Reddit thread: https://www.reddit.com/r/tinycode/comments/2rzuwp/da_here_h_2_h_da_h_2_the_metacompiler_of_cmforth/ ```cardlink url: https://youtu.be/umSuLpjFUf8 title: "\"Concatenative programming and stack-based languages\" by Douglas Creager" description: "In this talk we’ll explore stack-based programming languages, in which your program operates directly (and only!) on a stack of values. It might seem dauntin..." host: youtu.be favicon: https://www.youtube.com/s/desktop/d2ab3412/img/favicon_32x32.png image: https://i.ytimg.com/vi/umSuLpjFUf8/maxresdefault.jpg ``` # References ## Footnotes [^1]: Dave Gauer, [Ratfactor: Forth in Space](https://ratfactor.com/forth/forth-in-space) (2023-2025) [^2]: James Rash, [Forth in Space Applications](https://www.forth.com/resources/space-applications/) (2003) Recreated from an Internet Archive capture, hosted on `Forth.com` [^3]: [GreenArrays Products](https://www.greenarraychips.com/home/products/index.php) [^4]: https://duckduckgo.com/?q=FORTH+Reduced+Instruction+Set+Computer+%22frisc%22&t=ffab&ia=web [^5]: Carl Claunch, [Restoring the original source code for FORTH on the IBM 1130](https://rescue1130.blogspot.com/2018/03/restoring-original-source-code-for.html) (2018) [^6]: https://en.wikipedia.org/wiki/RCA_1802?useskin=vector#Programming_languages [^7]: Andy Yuen, [A Tiny Preemptive Multitasking Forth](https://web.archive.org/web/20170530202639/https://collaboration.cmc.ec.gc.ca/science/rpn/biblio/ddj/Website/articles/DDJ/1996/9603/9603h/9603h.htm) **archived**