#HowToThing #029 — One for the #Forth friends: Minimal livecoding playground for animated 2D geometry generation (incl. SVG export) using a Forth-like DSL (domain-specific language) based on https://thi.ng/pointfree, https://thi.ng/pointfree-lang and various geometry related operations using https://thi.ng/geom. A short screen recording is included to demonstrate overall usage. This is a cutdown version of a prototype tool, originally from 2019...
Even though the language is "Forthy", the underlying thi.ng/pointfree implementation does _not_ use a VM, but instead compiles words to vanilla JavaScript using normal functional composition (or reductions) and each word is passing data & state via a single shared stack context object (with the usual dual data & return stacks and an environment object with var bindings). The language supports quotations, local variables, combinators etc.
I _highly_ recommend consulting the detailed readme docs for the above packages to familiarize yourself with the basic principles & language features/syntax. If you do have some prior #Forth knowledge, many aspects should feel familiar (apart from the geometry DSL terms)...
Also worth pointing out that the editor/interpreter in this small example is not super forgiving re: error handling and might easily crash when live coding. The point of this demo is not about providing great UX, but to illustrate how the basic thi.ng/pointfree language infrastructure can be easily extended/adapted/integrated...
Demo:
https://demo.thi.ng/umbrella/pointfree-geom/
Source code:
https://github.com/thi-ng/umbrella/tree/develop/examples/pointfree-geom/src
(Note: The source code of the actual language bindings for the geometry operations is not shown here, but available in the `lang.ts` file, linked above...)