Crazy Computer Science Concepts (#1)
Lattice · 1,538 words · 8 min read · EN-ORIG

Below is the complete, readable transcript of Crazy Computer Science Concepts (#1) by Lattice on YouTube. Read the full text, copy any part you need, or generate a transcript for any video with our free tool.
In computer science, there are a lot of cool concepts. [music] Some that are interesting, mind-bending, and even some that resemble life itself. You see, the basic building blocks of all life are [music] cells, and cells contain DNA, which has the ability to replicate itself. But, can a program do that? Well, what if I asked you to make a
program that does exactly that? Replicate itself. And for the sake of simplicity, let's start off with a simple goal. Make a program that prints its exact self. And you're probably thinking that sounds simple, and you might be envisioning something like this. But, run it and it doesn't print the program you wrote, it prints this.
And these are obviously not the same, [music] and you can't fix it just by adding more prints because every fix adds more code, which is now more code that you'd also have to print. So, in order to do this, you need something more clever. [music] And there's actually a term for this kind of program
that can print its exact self, and it's called a quine. Here is a simple example of one in Python. So, how does this work? Well, let's start with the second line where we try to print S percent S, >> [music] >> which means print S, and when we run into a placeholder value inside of S
denoted by a percent symbol, fill it with this value, [music] which is also S. So, let's do it. We start by printing the value in S until we see a placeholder. And now, when Python reaches this percent R, it replaces it with the string S itself, including the quotes. And after the rest of the print
finishes, we are left with this. And we see that the program and the output are exactly identical, which means this is a quine. And so, you might be thinking, why does this even matter, and what significance is there in a program printing exactly itself? Well, imagine you change the quine. So, instead of
Transcribe another video
Paste any YouTube, Instagram or TikTok link to get a free transcript.