A Forth-inspired language for writing websites
4 hours ago
- #Web Development
- #Stack-Based Language
- #Programming
- The author has created a stack-based language called Forge, inspired by Forth, for writing websites.
- Forge allows users to define words or functions that generate HTML elements and microformats, enabling easy webpage composition.
- Website structure consists of pages (.forge files), a shared word library (lib.forge), and a stylesheet (style.css).
- A single binary compiles Forge to HTML using WebAssembly, supporting both server-side rendering (for SEO and WebMentions) and client-side rendering via a service worker for a single-page application experience.
- The language supports interacting with persistent storage, such as state, localStorage, or an append-only server log (JSONL format), illustrated by features like adding a "like" button.
- Forms in Forge can submit to other .forge pages, where data is handled on the stack and can be logged using built-in functions.
- The author experiments with Forge as a personal creative project, finding the language's constraints interesting and considering using it for their own site.