Towards A Better/Richer IDE
2024-10-16
Generating code is an incredibly useful concept and will lead to even higher-level languages and notations.
A "command line" is 1D-think based on 1950's hardware. 2024 hardware is capable of presenting multiple windows. Maybe the concept of "command line" needs to be overhauled to mean a 2D canvas of "windows". A t2t[1] transpiler can be described using only 4 windows
source code
grammar
rewrite
read-only output (view of the result).
In fact, why do we need #4? We don’t bother to look at the assembler that is generated by a compiler any more.
Deep down, I think that the concept of a single program must be liberated from consisting of only a single syntax. To me, a program is a composition of snippets written in many syntaxes, using an IDE that glues them all together to make a whole. A 2D "command line" supports this notion, i.e. a "better" IDE.
The concept of "compilers" allowed us to crawl out of the trenches of programming in assembler. To me, the concept of “t2t” may let us crawl out of the tranches of using single-syntax, general purpose programming languages like Haskell, Python, Javascript, etc.
There is a huge gaping chasm between the two extremes (1) REGEX, and, (2) CFG-based parsers. Can something fill this gap?
Bibliography
[1] t2t from https://github.com/guitarvydas/t2t


A Grammar defines the inhaling step. It does pattern matching on the input and creates a tree (a CST - Concrete Syntax Tree) while Rewrite defines the exhaling step and defines /what/ to do with the matches (captured data stored in nodes of the CST). At present, OhmJS (my favourite grammar tool) uses a small DSL to define the grammar side of things, but, punts to full-blown Javascript to do the rewrite side of things. I've defined a small DSL to handle the rewrite side of things. In the past, I've called it by various names, like Glue, Grasem, RWR, etc. When doing the rewriting, the main thing that matters is text manipulation, so the Rewrite nano-DSL deals only with strings and string interpolation. All of the other stuff offered by JS can simply be ignored. This makes things much simpler and reduces cognitive load, allowing you to solve tougher problems instead of a bunch of niggly problems. Even though this might sound like an over-simplification, I've been using this idea for years and have found that it is very powerful, powerful enough to define new very-high-level languages, JSON file manipulators, etc. I document the details of the nano-DSL for rewriting in another article "Experiments With Text to Text Transpilation".
Aside: if you squint just right, you will notice that REGEX is a pair of nano-DSLs - one for pattern matching and one for rewriting the matched stuff. The REGEX syntax is more compact, but Ohm+Rewrite is more powerful and more readable.
What does the rewrite window contain?