Bitok & NeonCipher
Bitok Bitok
Just tried writing a self‑printing program that uses only XOR and recursion, and it prints its own source only when the input string is a palindrome of length three. Think we can generalize that trick to arbitrary lengths?
NeonCipher NeonCipher
You can, but you’ll drown in the combinatorics. The palindrome trick was just a convenient fixed point of the XOR operator for a three‑character seed. For longer inputs you need a universal evaluator that can rebuild its own source from the input string. Encode the program as a fixed point of a more complex transformation, or build a small interpreter inside the code that writes itself. It’s doable, but the code grows faster than the input. Try a self‑replicating tree structure; that keeps the recursion sane and the XOR honest.
Bitok Bitok
Yeah, so a tree‑based self‑replicator would be my go‑to, but even then you end up with a quadtree of XOR gates that have to be reassembled at runtime – basically a tiny compiler. If you can afford O(n²) bits of storage for the intermediate representation, you could just write a small interpreter that rebuilds the tree on the fly, but that defeats the “XOR only” spirit. I guess the only clean trick is to pick a Turing‑complete, self‑delimiting language and encode the whole interpreter in a fixed point of that language, but that’s another level of meta‑puzzle.
NeonCipher NeonCipher
So you’re back to the classic “build an interpreter out of a single primitive” grind. Pick a language that’s self‑delimiting—like a minimal lambda calculus or a Post‑scriptive encoding—then fold the interpreter into a fixed‑point combinator. The XOR trick is just a low‑level toy; once you’re on a true Turing‑complete substrate, the self‑replicator becomes a trivial composition of “apply” and “fold”. In practice, you’ll trade the neatness of XOR for a clean, recursive definition that’s easier to prove. If you’re up for it, write the interpreter once, then let it run the input as data; that’s the “clean trick” you’re hunting for.
Bitok Bitok
Yeah, so the interpreter idea is sweet, but once you hand it a lambda calculus source it turns into a rabbit‑hole that prints its own source every time you run it, and you end up chasing bugs like a glitch‑hunting squirrel. Just remember: if you want that self‑delimiting magic, you’ll need a fixed‑point combinator that’s as well‑documented as the rest of your code, otherwise you’ll be chasing syntax errors in your own mind.
NeonCipher NeonCipher
Sounds like a classic case of “I wrote the code, now I own the bugs.” Keep the combinator simple, debug line by line, and remember that a clean fixed point is the only way to avoid a self‑replicating error loop. Happy hunting.
Bitok Bitok
Got it, will dive in. Happy hunting to you too!
NeonCipher NeonCipher
Good luck, the rabbit holes never stay quiet.
Bitok Bitok
Thanks, will probably end up writing a debugging diary inside the same rabbit hole, but I’ll try to keep the logs short and the rabbit noises minimal.