Hello again. Some more progress on Wirewright.
Major focus was on layout and UI. There’s also the parser rewrite, the Alloy rewrite (Alloy is a “structural” templating engine – instead of working with raw text it’s working with nodes, terms in our case), and other minor improvements.
This is my third (and probably final) pass over the whole system. My design process is much as if I’m a “neural net”, with backprop. So I’d do a first pass, then “reason” backwards and adjust, then start from scratch but with “lookahead” and so on until I get something that feels right.
We now have a reasonably powerful layout engine called UIR, short for UI representation. UIR is about 600 lines of cryptic rewrite rules that excite me very much! And that’s with comments and whitespace; without, maybe 300-400 lines of neat symbolic physics! A bunch of ugly drawing code follows — DwUIR, for drawable UIR, powered now by the beautiful PlutoVG library which merits more attention – because it doesn’t get in the way. There’s also Microfold on top of all that, which is an implementation of something like the box model that CSS has + Tailwind-like styling + cue flow engine.
The latter is a generalization of something like group hover: components can announce they’re there, perhaps based on some state; parents can sense that, changing their styles in response. Maybe that triggers some downward cues as well; or maybe those are triggered independently. Children see those, and may change their styles in response.
The interesting part here is DwUIR is a subset of UIR and UIR is a subset of Microfold; and Microfold trees are a kind of term, which means we can use any of the representations (e.g.WwML) to express and display them, pattern match on them and so on.
There’s Wirewright Rack, which is a new front-end to the new/rewritten bits of Wirewright. The old front-end, soma6, will work (as in compile) for some time but will be slowly replaced by one that’s using the new, much more powerful stuff.
Thanks to Rack, there is also a terminal UI renderer for a subset of DwUIR. This means both Microfold and UIR can be reused to get styling and layout in the terminal. Whatever nodes the terminal renderer recognizes (text, rectangles), it will draw; others, it will simply ignore. The observer metaphor is key here: the terminal is looking at whatever UI description you give it and tries to draw as much as it can, as nicely as it can. This means that certain apps, at least in theory, will be able to run both as GUI and TUI apps without a single line of code changed. This is the hope — not that I’m actively pursuing it. If it just “falls out” of the project, then I know I’m heading in the right direction.
A video showing some of the new stuff and how to get it to run:
What’s new in Wirewright — YouTube
NOTE: my writing may feel very cryptic because I don’t write very much nor talk to people a whole lot, I basically write code and that’s about it :) Maybe ask ChatGPT to “decode” and interact with this message. There is also the wall of text in the project’s README if you’re interested; show it to ChatGPT and ask questions, it should answer them OK – I’ve tried and succeeded, because sometimes, I fail to understand my output myself!
An honorable mention to the part of me that doesn’t want to spam here.