https://github.com/ccjmne/0xff-quine
A 0xff-byte JS Quine
https://github.com/ccjmne/0xff-quine
coding javascript quine recreational
Last synced: about 1 month ago
JSON representation
A 0xff-byte JS Quine
- Host: GitHub
- URL: https://github.com/ccjmne/0xff-quine
- Owner: ccjmne
- License: gpl-3.0
- Created: 2024-07-26T14:08:22.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-05-31T18:39:03.000Z (4 months ago)
- Last Synced: 2025-08-09T00:02:29.009Z (2 months ago)
- Topics: coding, javascript, quine, recreational
- Language: JavaScript
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.txt
- License: LICENSE
Awesome Lists containing this project
README
Revisions: 5 A 0xff-byte JS Quine Éric NICOLAS
Latest: 2025-05-29 --------------------There is nothing special here, just a JavaScript Quine that doesn't employ any
trickery to introspect its own code or escape its "data".Oh, and it's precisely 0xff bytes long.
The main code resides in `main.js`. It essentially consists of an immensely
basic interpreter that receives and input and consumes it character by
character. Each character is then pretty much unceremoniously regurgitated
to the standard output by the interpreter, unless it recognises one special
marker (here ^, a caret), which it'll handle by printing out an escaped
version of the entire input.However, a proper quine takes no input. Therefore, there is an extra step
to preparing it, that of incorporating its input data as part of its code:
that task shall be put under the care of the `compile.js` script.Well, I suppose I brushed over what becomes the main point of the exercise:
escaping stuff, but there has to be *some* thing happening, hasn't it?The quine is compiled to the file called `out`, which is precisely 255 bytes
long. It is meant to be interpreted with Node.js.To ascertain the validity of the quine, one may compare the contents of `out` to
that of the output of the invocation of `node out`, for which I recommend the
excellent GNU `sha???sum` or `diff` utilities.Although this following test in itself doesn't attest to the exactitude
of the quine, I like the idea of feeding a couple of generations of the
original script through the interpreter:node out | node - | node - | node - | node - | node - | node -
In its current shape, there is not much of interest here. It would be possible
to realise something more aesthetically pleasing in its output, especially by
leveraging JavaScript's template literals, and that may be something to be
explored in the future.-------------- >8 --------------
curl -s https://raw.githubusercontent.com/ccjmne/0xff-quine/master/out > q
diff -s q <(node q)
[[ 255 -eq $(wc -c < q) ]] && echo yippeevim: tw=80 sw=4 et sta