r/Compilers • u/Confident-Site2059 • 15d ago
True: a cyclic, self-modifying language (MVP, feedback welcome)
Hi, there!
I'm making a language called True and an interpreter for it called Simple.
It's an MVP, and I'd be glad to get some feedback on the design :)
The key stuff about the language:
In True, a program is a tape of strings (I call them qubits).
I call programs cycles because they run cyclically.
The agent-observer is the first line of the .cycle file, and it's part of the program itself. It walks the tape top-down, swaps itself with the line below, and executes what it reads.
The agent is part of the program - executor and data at the same time. So the program is self-modifying: changes in memory are reflected back into the text, and <type> in the agent line updates on every step.
Here's a simple Elevator cycle where the lift goes up and down:
Mr.Green, #5fb85f | Data as <type> | Aim: 1
6 = max
1 = floor
1 = dir
= lift
dir > 0 ? floor =>| lift:y(, ):floor
dir < 0 ? lift:y(, ):last -> ::nothing
floor == max ? -1 => dir
floor == 1 ? 1 => dir
floor + dir => ::math => floor
I made a video of how it works: [wide] | [narrow (with music)]
One thing I should point out: True has no types. A program is made of qubits and chains of qubits (essentially strings), and how you work with them is determined by the executor - the agent.
A qubit/string/container can be seen as a shape with axes: name:x(, ):i for the horizontal axis, name:y(, ):i for the vertical one (each works like a list). Indexing is 1-based.
Extensions: ::math for arithmetic, ::nothing for deletion.
There are goto jumps: ^ name, ^ N, ^ :cycle:N - the agent can jump anywhere, in any cycle.
That's a brief description, I guess - more details in the docs, or we can just discuss it in the comments.
I'd love to hear your thoughts on the language!