Live data from Hacker News

Modal is a matrioshka language based on pattern-matching to rewrite trees

wiki.xxiivv.com

21–23 of 23 posts

Re: Modal is a matrioshka language based on pattern-matching to rewrite trees

#22
post #14

Seems like something that could be leveraged in optimization and AST lowering with great success. Admittedly the examples on the main page aren't well explained, so requires a bit of groking. Really cool looking stuff though.

That's what I thought it was based on the title -- I've been looking for a simple tree-rewriting library (or DSL) for a while now. Treecc[0] is probably the closest I've found and AFAICT would have to be beaten into submission to provide similar functionality. Plus its been abandoned and quite complicated methinks. There was a project doing almost exactly what I wanted but in a different domain but, unfortunately, my…

Tree rewriting is at the core of many compilers, but many compilers are huge labyrinths with historical cruft.

You might find inspiration in Go, though, as that compiler is surprisingly simple in structure. The SSA rewrite rules look like

    (Add8   (Const8 [c])   (Const8 [d]))   => (Const8  [c+d])

    (EqPtr  x x) => (ConstBool [true])
https://go.dev/src/cmd/compile/internal/ssa/_gen/generic.rul...

https://go.dev/src/cmd/compile/README

Re: Modal is a matrioshka language based on pattern-matching to rewrite trees

#23
post #8
post #7

Earlier quoted context omitted.

Oh I see, very cool. Would be interesting to see basic graphics programming using it - the aesthetics of the page and how it's presented are very intriguing, but a little esoteric/mysterious (perhaps intentionally so).

Devine and a few others are actually working that out! We're collaborating in the Concatenative Languages Discord server on how to use, extend and improve the language.

Awesome, looking forward to it.

Aesthetically and everything else - I would love to see a Conway's Game of Life or maybe a Terminal-based platformer RPG, or a digital art installation that takes over my computer like a virus - something to that effect in this language.

The whole picture: Everything you've said, the way your site presents it, the way you talk, and a video of a very impressive low-bit program.

I think it would trend!

Post reply on HN