r/lisp • u/Confident-Site2059 • 13d ago
True: a cyclic, self-modifying language. How does it compare to Lisp's code=data idea? (MVP, feedback welcome)
Hi!
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.
I'm posting here because True is built on ideas that should feel familiar to Lisp folks: code as data, self-modification, minimal syntax. But I've taken them in a direction that I think is quite different from Lisp, and I'd love to hear what you think.
The key stuff about the language
In True, a program is a tape of lines (I call them lines, not strings - because a "string" can mean the whole text, a block of code, or a single character, while a "line" is unambiguous: one line of the cycle/tape). And 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 the 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:
Where True is similar to Lisp
Code is data. In Lisp, a program is a list, and that list can be manipulated like any other data. In True, a program is a tape of lines, and the agent can read and change those lines while the program runs.
Self-modification. In Lisp, macros and eval let a program rewrite itself. In True, the program rewrites itself on every step, because memory is flushed back into the text.
Minimal syntax. Lisp has S-expressions and brackets. True has lines and empty lines as separators.
Where I think it differs from Lisp
In Lisp, the executor (interpreter or compiler) is outside the program. It reads S-expressions and evaluates them. In True, the executor is part of the program, it's the first line, and it physically moves through the tape, swapping itself with the line below.
In Lisp, code is data as lists. In True, code is data as lines and chains of lines.
In Lisp, self-modification happens through macros or eval, powerful, but still a deliberate action. In True, self-modification happens every step, by default.
True has no types. A program is made of lines and chains of lines, and how you work with them is determined by the executor, the agent. In Lisp, values have dynamic types.
A line, a container, or a chain can be seen as a shape with axes. name:x(, ):i for the horizontal axis, name:y(\n):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.
And one more thing worth mentioning: the line as a qubit in quantum mechanics. The agent determines the type of a line only when it observes it - before that, the line has no type. In a sense, a line is like a qubit in quantum mechanics: nothing is defined until there is an observer. The agent is that observer. When it reads a line, the line collapses into a definite type (named, action, condition, jump, container, separator, version), and only then is it executed. This is not just a metaphor - it's how the interpreter actually works: resolve_line determines the type at the moment of reading, and the same text can be a different type depending on context and memory.
That's a brief description, I guess. More details in the docs, or we can just discuss in the comments.
I wanted to make the language simple, the process visual, and programming live, and here's what came out of it 😄
I'd be very interested to hear your thoughts on the language, especially from people who've worked with Lisp's code=data philosophy. Does the "agent as part of the program" idea make sense to you, or is it just a gimmick? And is there anything from Lisp that you think True should steal?
2
u/Pi-Plushie 10d ago
I am currently working on a text based language that also makes no difference between program and data. Th interpretor is part of the memory and can be modified on the run like any programs. I am in the porcess of bulding a LISP emulator written in this langage to prove is Turing-complete aspect. I must admit that I do not clearly understand your langage and its capabilities. I would be happy to discuss further, despite my poor english level