=================================================================================== Bootstrap yourself into conviviality by writing your own Forth David Frech 2008 March 30 DorkbotPDX 0x01 =================================================================================== This talk is dedicated to all Makers. "We make in order to know." Making creates knowledge in our bodies. We are wired to do it. It is a key part of being human. The world of made objects is an inexhaustible source of inspiring & intoxicating beauty. =================================================================================== What do these terms mean? What do we mean by * Forth * Bootstrapping * Conviviality =================================================================================== What is Forth? * Forth aphorism: "Forth isn't a language, it's an environment." * My response: Forth is an idea, not a language. * Forth aphorism: "If you've seen one Forth, you've seen one Forth." * Reality: simplicity & extensibility create a tower of Babel =================================================================================== Concretely, what is Forth? * Trivial syntax: whitespace-separated tokens * Trivial compiler: words are simply sequenced * Two stacks: allows words to consume and generate variable numbers of arguments * Everything is executable * Reverse Polish Notation (RPN) * tokens are simply executed left-to-right * Dictionary - two senses: * the "heap" - all the words and their data * the association of tokens with their code =================================================================================== What is bootstrapping? * Originally, idea of pulling yourself up, off the ground, by pulling on your bootstraps. * Needs an "external input of energy" * Examples: * booting Linux * creating a new Forth by meta-compiling * creating an "application" by extending Forth (incremental bootstrap) * Meta-circular * Self-referential * Recursive =================================================================================== What is conviviality? What are convivial tools? * Ivan Illich, _Tools for conviviality_ a critique/postscript for the industrial age * E F Schumacher's _Small is beautiful_ is similar * Convivial != easy to learn or use well * Alan Kay: pencil as mundane computing device * Industry can stifle conviviality while creating convivial tools (microcontrollers are a good example) * Human languages are convivial. Why aren't most computer languages? * Conviviality as a measure (index of liberation) =================================================================================== Forth is simple but powerful. Why is this? * Code being read in can affect the parser & compiler * Trivial parser and compiler are easy to modify & "misuse" * "Writing the reader" - a trait shared with Lisp & Smalltalk * Live system - all of Forth available, all the time * Extensible via colon words, code words, and new data types =================================================================================== A brief history of Forth * Chuck Moore invents (some say "discovers") Forth * polyFORTH * fig-FORTH * ANS * colorForth =================================================================================== Where is the Forth community? * A dead language? * No good books available * SVFIG a disappointment * Implementors have moved on * gforth is a good implementation, but big and unapproachable - and ANS. * Chuck continues to innovate, but his work is inaccessible, literally and figuratively =================================================================================== Why muforth? * It all started with fig-FORTH (ca 1980) * dforth (ca 1997) * written in 486 assembler, tied to Linux, hard to modify, hard to understand * Once again, we make in order to know. I wanted a platform for experiments, a substrate for building target compilers for microcontrollers * muforth, native-coded (ca 2002) * trivial compiler * tail-recursive * even a trivial compiler can be hard to port * muforth, indirect-threaded (ca 2005) * slower but portable * a simpler model of Forth =================================================================================== muforth's innovations * hybrid of C & Forth * self-bootstrap * no numbers * no control structures * no data types * token consumers * simplicity of creating new interpreter "modes" =================================================================================== Sources & resources muforth git clone https://github.com/nimblemachines/muforth.git browse https://github.com/nimblemachines/muforth/tree/master Tools for conviviality http://clevercycles.com/tools_for_conviviality/ (hard to read; style to be narrower) colorForth http://www.colorforth.com/ HOPL Forth history paper http://www.colorforth.com/HOPL.html Brad Rodriguez's (good) Forth implementation articles http://www.zetetics.com/bj/papers/index.html Brad's CamelForth http://camelforth.com/news.php ===================================================================================