Programming your way 
back to where you were 
Riviera.rb 
5 March 2013 
Jean-Baptiste Mazon 
@jbmazon
Introduction 
● What 
● Cheats 
● Hacks 
● Language features
A quine is a computer 
program which takes no 
input and produces a copy 
of its own source code as 
its only output. 
The...
Well-known pattern 
D 
R 
Y
Well-known pattern 
Do 
Repeat 
Yourself
IOCCC 1994: smr
IOCCC 1994: smr 
(categorized: Worst Abuse of the Rules)
The recursive aproach 
(live demo)
ASCII quine 
(live demo)
Generic quine 
(but it's still ASCII-based) 
(live demo)
A brief math digression 
● Fixed-point theorem 
● Cool functions to fix 
– print source 
– interpret 
– compile 
– gzip so...
Quines
Quines
Quines
Quine
Quine 
● “Yields falsehood when 
preceded by its quotation” 
yields falsehood when 
preceded by its quotation.
Quine 
● “Yields falsehood when 
preceded by its quotation” 
yields falsehood when 
preceded by its quotation. 
● quine “h...
Terminology 
● code 
● data 
● intron
Bootstrapping
Multiquines
Examples
Examples 
● (λx.xx) (λx.xx)
Examples 
● (λx.xx) (λx.xx) 
● #!/bin/sh 
cat $0
Examples 
● (λx.xx) (λx.xx) 
● #!/bin/sh 
cat $0 
● #!/bin/cat
Examples 
● (λx.xx) (λx.xx) 
● #!/bin/sh 
cat $0 
● #!/bin/cat 
● puts(s = <<e, s, 'e') 
puts(s = <<e, s, 'e') 
e
Examples 
● (λx.xx) (λx.xx) 
● #!/bin/sh 
cat $0 
● #!/bin/cat 
● puts(s = <<e, s, 'e') 
puts(s = <<e, s, 'e') 
e 
● Q
Other examples
Final thoughts 
● incompleteness 
● trusting trust 
● Quine Central 
● backup 
● introspection 
● anything else?
References 
● Wikipedia 
● David Madore's quine page 
● C2 
● Russ Cox's “Zip Files All The Way Down” 
● Dan Piponi's “Qui...
Upcoming SlideShare
Loading in …5
×

Quines—Programming your way back to where you were

639 views

Published on

My 2013-03-05 Riviera.rb quines talk slides. I'm afraid there's not much left without the speech and live demos.

Quines are programs (or, more generally, concepts) that reproduce themselves. During this talk we explored how they were possible, what they could look like, how to generate them and how to generalize them,

Published in: Science
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
639
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Quines—Programming your way back to where you were

  1. 1. Programming your way back to where you were Riviera.rb 5 March 2013 Jean-Baptiste Mazon @jbmazon
  2. 2. Introduction ● What ● Cheats ● Hacks ● Language features
  3. 3. A quine is a computer program which takes no input and produces a copy of its own source code as its only output. The standard terms for these programs in the computability theory and computer science literature are self-replicating programs, self-reproducing programs, and self-copying programs.
  4. 4. Well-known pattern D R Y
  5. 5. Well-known pattern Do Repeat Yourself
  6. 6. IOCCC 1994: smr
  7. 7. IOCCC 1994: smr (categorized: Worst Abuse of the Rules)
  8. 8. The recursive aproach (live demo)
  9. 9. ASCII quine (live demo)
  10. 10. Generic quine (but it's still ASCII-based) (live demo)
  11. 11. A brief math digression ● Fixed-point theorem ● Cool functions to fix – print source – interpret – compile – gzip source
  12. 12. Quines
  13. 13. Quines
  14. 14. Quines
  15. 15. Quine
  16. 16. Quine ● “Yields falsehood when preceded by its quotation” yields falsehood when preceded by its quotation.
  17. 17. Quine ● “Yields falsehood when preceded by its quotation” yields falsehood when preceded by its quotation. ● quine “hello”. → hello “hello”.
  18. 18. Terminology ● code ● data ● intron
  19. 19. Bootstrapping
  20. 20. Multiquines
  21. 21. Examples
  22. 22. Examples ● (λx.xx) (λx.xx)
  23. 23. Examples ● (λx.xx) (λx.xx) ● #!/bin/sh cat $0
  24. 24. Examples ● (λx.xx) (λx.xx) ● #!/bin/sh cat $0 ● #!/bin/cat
  25. 25. Examples ● (λx.xx) (λx.xx) ● #!/bin/sh cat $0 ● #!/bin/cat ● puts(s = <<e, s, 'e') puts(s = <<e, s, 'e') e
  26. 26. Examples ● (λx.xx) (λx.xx) ● #!/bin/sh cat $0 ● #!/bin/cat ● puts(s = <<e, s, 'e') puts(s = <<e, s, 'e') e ● Q
  27. 27. Other examples
  28. 28. Final thoughts ● incompleteness ● trusting trust ● Quine Central ● backup ● introspection ● anything else?
  29. 29. References ● Wikipedia ● David Madore's quine page ● C2 ● Russ Cox's “Zip Files All The Way Down” ● Dan Piponi's “Quine Central”

×