I'm Wryl, the original author of this language. I sketched it out in late 2018 and played with it in 2019 after seeing some Mill architecture articles floating around. I mostly created it out of spite, thinking "You don't need fancy designs to do high-level things on bare metal!"
At the time, I called it a term rewriting language, which seem a bit of a weaker label than what it is. It's more like a string rewriting system with variables and nested strings, with parentheses acting as the separators for sub-strings.
It got to the point where I could transcribe Quicksort from the Haskell wiki into a fragment of Modal. I stopped playing with it after I had some not-so-fun industry experiences, and declared my work a dead-end.
Devine from Hundred Rabbits managed to get me to talk about it a bit more, and has taken the language far beyond what I could dream of. It's now gone beyond a sketch to a genuine marvel of engineering which is continually being refined as we figure out more idioms. The language is in very good hands.
I'm of the opinion that rewriting is an unexplored paradigm, and that we don't really understand how to build software. Modal was a product of my research efforts, which are still on-going. I hope to bring more projects like this to light. This has been quite fun.
Term rewriting is woefully overlooked, maybe because the paradigm is rather open-ended. Questions about fixed or variable arity, what rules to apply in what order, what kinds of pattern matching to support, can make the language very limited or intractably inefficient depending on the answer.
I like that Modal just rolls with Peano arithmetic rather than awkwardly bolting on numerics. It's impractical, but it doesn't have to be practical - this is an exploration of a concept
What's nice about rewriting as a concept is that bolt-on extensions to make things fast don't have to be awkward.
Built-in rules that take priority over user-defined ones, as well as special variables in Devine's implementation, allow us to gain back speed while retaining some idea of purity. We know these operations can be phrased in terms of rewrite rules, so let's shortcut them and use built-in arithmetic in place.
You'd never know the difference! There's also a lovely arithmetic library built by d6 that you may enjoy. It does arithmetic digit-by-digit, and they're continually improving it to run faster.
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.
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 indexing skills are subpar and I can't remember what it was called so it's lost...
I recall the feeling, being one of many who "rediscovered" Gröbner bases. This is why one studies history, to recognize the taste when one is a turn away from new history:
There was a leap needed, to generalize Gaussian elimination and the Euclidean algorithm to their common ground of arbitrary polynomials. There's a further leap to noncommuting strings, and then there's typed trees, the "algebraic datatypes" foundation of languages like Haskell and Lean 4. To see term rewriting in these settings as a continuum, one needs to incorporate recursion, to understand how Schützenberger's notions of rational and algebraic languages apply.
The idea of a term ordering is too gnarly here (well past the interstellar frontier of "decideability") for anything besides human intuition or deep learning.
Nevertheless, one sees that term rewriting on typed trees can be the foundation of human thought. Deep learning, while impressive, struggles to simulate recursion using multiple layers. We are discovering exactly how fundamental recursion is to thought. A version of neural nets more closely based on a probability substrate of typed trees might more adeptly model thought.
Not particularly, no. Nothing specific. The semantics of the language lend themselves well to an implementation in hardware. I had a sketch in VHDL in the time I spent developing this.
This means that the above sample is effectively your "assembly language". There was no gap between your programs and the hardware they ran on.
Modal can be used to write small utilities, games, programming language implementations, type systems.. the list goes on. It's a fully general meta-language that can be used for general purpose programming.
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.
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'm Wryl, the original author of this language. I sketched it out in late 2018 and played with it in 2019 after seeing some Mill architecture articles floating around. I mostly created it out of spite, thinking "You don't need fancy designs to do high-level things on bare metal!"
At the time, I called it a term rewriting language, which seem a bit of a weaker label than what it is. It's more like a string rewriting system with variables and nested strings, with parentheses acting as the separators for sub-strings.
It got to the point where I could transcribe Quicksort from the Haskell wiki into a fragment of Modal. I stopped playing with it after I had some not-so-fun industry experiences, and declared my work a dead-end.
Devine from Hundred Rabbits managed to get me to talk about it a bit more, and has taken the language far beyond what I could dream of. It's now gone beyond a sketch to a genuine marvel of engineering which is continually being refined as we figure out more idioms. The language is in very good hands.
I'm of the opinion that rewriting is an unexplored paradigm, and that we don't really understand how to build software. Modal was a product of my research efforts, which are still on-going. I hope to bring more projects like this to light. This has been quite fun.