Forem

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

Posted on

4 2 1 2 2

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.

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

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

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay