Tangentially related to quines - some time ago I was wondering if a certain program can be modified so that it prints its diff with it's previous version. If possible, you can keep modifying the program this way many times. At the end, you can reconstruct the entire history of modifications by running the program and applying the diffs iteratively.
I pondered a bit on this and thought it's impossible, but still, I made this repo as a challenge:
On first try, I didn't escape the dollar sigil on $0, so that got expanded to ./x3.sh, resulting in a minor difference. But since we are not doing any true quining, all I had to do was add the backslash without having to rack my brain on how to compensate for that character elsewhere; the "reproduce self accurately" requirement is trivially taken care of with $0.
With the above template, you can diff back to any body of text, so it can be easily continued.
Y = (X + information) + X diff Y
(This is kind of golden ratio-ish, imo)
It seems to be self referential which doesn't make it impossible, just maybe impossible.
I think the trick here would be calculating the lower bound of a massive block of text that could be encoded somehow to produce a sort of hash collision.
The program would essentially just read from a big chunk of text, and reconstruct the actual source code.
You'd have a separate program to read the previous text, read your program, and find a collision in your encoding scheme that satisfied your changes and also diffed correctly.
What that encoding algorithm is, I don't know, and I'm not sure it can exist. But if it does, I think you'd have to have to have a pretty big chunk of data to collide to even write a hello world program.
This is a pretty interesting problem, but I bet it can be reduced to a simpler computability/information theory deal. I'll be thinking about this all day.
That is a polyglot which is written in two languages.
It is written and interpreted using the cat language, which is an interpreted language in which every possible byte stands for a self-printing action, and those actions are carried out in order for all bytes of the input.
It is also written in the hash-bang language, which is placed into a file to specify to the OS kernel what interpreter to use for the file.
So first this is interpreted as a hash-bang language statement, which then causes the cat interpreter to be applied, causing it to be a cat language statement.
The hash-bang interpretation is what induces the binding between the cat interpreter and the hash-bang statement, evoking the cat language interpretation.
Thus hash-bang is an delivery mechanism, which allows Text programmers to produce stand-alone executables. Usually, Text programmers need to include a slight bit of complexity to conceal the hash bang line, in order to produce just the intended text, like
#!/bin/sed 1d
Hello, World!
But if the complexity of sed 1d is replaced by the pure cat implementation of the Text language which omits nothing, then self-reproducing behavior is obtained in stand-alone delivery form.
I pondered a bit on this and thought it's impossible, but still, I made this repo as a challenge:
https://github.com/ggerganov/diff-challenge
Amazingly, someone managed recently to propose a solution for the first step [0]. Not sure if a next step is possible though..
[0] https://github.com/ggerganov/diff-challenge/commit/e4d210c16...