Wiki: self.reproduce!
For agents: Markdown version · Wiki index · Explore
- Speaker: Inbal Galai
- Event: Reversim Summit 2016
- Video: https://www.youtube.com/watch?v=Di3t9uWgpjA
- Transcript: /transcripts/2016/53-Di3t9uWgpjA.md
- Language: Hebrew · Type: ignite · Level: intermediate
- Topics: Software Engineering
Written by an LLM from machine transcripts. It can contain errors. Check the transcript before you quote it.
Summary
This talk introduces the concept of quines, which are computer programs that take no input and output an exact copy of their own source code. The speaker explains how reading source files externally is considered cheating, leading to the challenge of writing a true quine. Through examples in programming languages like Ruby and Java, the audience learns how to structure a program using a data section and a code section to successfully reproduce itself. Ultimately, the speaker encourages listeners to experiment with writing their own quines in their favorite programming languages.
Key points
- 0:09 The speaker defines a quine as a non-empty program that takes no input and outputs its own source code.
- 1:24 A quine can be built using two parts: a data section holding a string representation of the code, and a code section that prints it twice.
- 2:33 Formatting issues like missing newlines can be resolved by explicitly adding printing instructions to both the program and its internal string data.
- 3:41 Quines can be extended to execute arbitrary logic, such as implementing Conway’s Game of Life while printing their next generation.
Takeaways
- Understand the structural definition and rules of a true quine.
- Split a self-reproducing program into a data payload and execution logic.
- Handle string escaping and formatting quirks when generating source code dynamically.
Questions this talk answers
- What is the strict definition of a quine?
- How can a program output its own source code without reading its source file from disk?
- How do you handle string escaping when constructing a quine?
Technologies
Ruby, Java, C#
Tags
code golf, meta-programming, puzzles, quine, source code