r/Compilers • u/Confident-Site2059 • 26d 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 => floorI 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!
View all comments
1
u/Confident-Site2059 26d ago
Let's make it more clearly:
This is a concept and an MVP. It’s not meant to be a real quantum language 😄
A qubit is just a string with an undetermined type: any type is possible until the agent (as the watcher) observes it. I borrowed the term from quantum mechanics as a metaphor: like a real qubit, this string has a value that depends on the observer.
Don't worry - there's no actual quantum physics here; it's just plain text (when you observe it 😂 ). If the term feels awkward, you can think of it simply as a string.
An agent isn't a program or a runtime. It's just the line in the file. What makes it special is that the interpreter reads it and moves it and uses it to drive the execution. All the lines are treated as data. So the agent is the executor that lives in the same file as the data - and it's also part of the data