r/Compilers • • 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 => 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!

3 Upvotes

2 comments sorted by

View all comments

1

u/Confident-Site2059 26d ago

Here is another one simple example:

1| Mr.Green, #5fb85f | Data as <type> | Aim: 1
2| 
3| 1 = a
4| = b
5| = c
6| 
7| a => b
8| b -> c
  1. Agent "Mr.Green" determines the line as:
  2. Empty unnamed container
  3. String 1 in the container named a
  4. Empty string in the container named b
  5. Empty string in the container named c
  6. Empty unnamed container
  7. Action to copy (=>) the value from container a to b ( a: "1"; b: "1" )
  8. Action to move (->) the value from container b to c ( b: ""; c: "1" )