Can you write a quine in SC?

Hi all,

This may be a dumb question, but is it possible to write a quine in SC?
Pretty sure those of you who can answer know what a quine is, but for the rest of us, it’s “a computer program which takes no input and produces a copy of its own source code as its only output” (from Wikipedia).

I know it’s not a terribly useful use case, but interested to know.

Perhaps slightly cheating(?) but:

value { "value" + thisFunction.asCompileString }


1 Like

Curious: why do you say that’s cheating?
It does print the whole thing, right?
Thanks!! Fascinating.

The examples folder included with SC contains a document titled quines.scd, described as

“// a conversation on quines, between Julian Rohrhuber, Jens Gulden and Tim Walters.”

Could be a good place to start! :slight_smile:


Wow, I never even thought that would be there. Thanks!

Here, I was able to track it down for everyone:

Platform.resourceDir +/+ "Examples/other/quines.scd"

…and there’s a few online, as well:

1 Like
1 Like

Yup, that’s a cheating quine Quine_(computing)#Self-evaluation

Here’s the smallest “cheating” quine in sclang:


Interestingly, an empty file doesn’t work in sclang because it would output nil :slight_smile:

Interesting – to literally take on the can-question in the title, i thought all Turing-complete languages can have quines, but now the seed of doubt has been planned in my mind…

An SCTweet Quine (by @nathan ?) :


This original one needed some adaptation because SC was warning about

Warning: size of wavetable not a power of two (COsc)
Warning: size of wavetable not a power of two (Osc)