DEV Community

Cover image for One Byte Explainer: What is a quine?
Eda
Eda

Posted on

One Byte Explainer: What is a quine?

This is a submission for DEV Computer Science Challenge v24.06.12: One Byte Explainer.

Explainer

The answer is "The answer is".
Also called a self-replicating program, a quine is a computer program that outputs its own source code. The sentence above tries to mimic one. Its practicality can be arguable, but it's an amusing metaprogramming concept.

Additional Context

Here is an example in JavaScript, adapted from Dylan Beattie's beautiful talk The Art of Code:

(f = () => console.log(`(f = ${f})()`))()
Enter fullscreen mode Exit fullscreen mode

When you run it, the output is:

(f = () => console.log(`(f = ${f})()`))()
Enter fullscreen mode Exit fullscreen mode

Cover image by ANIRUDH on Unsplash.

Top comments (2)

Collapse
 
thaisavieira profile image
Thaísa Vieira

That's so great, Eda! You explained it in a very clear way, there's nothing better than a simple example to understand something.

Collapse
 
gadekar_sachin profile image
Sachin Gadekar

nice