Transcript
Page 1: Quines—Programming your way back to where you were

Programming your wayback to where you were

Riviera.rb5 March 2013

Jean-Baptiste Mazon@jbmazon

Page 2: Quines—Programming your way back to where you were

Introduction

● What● Cheats● Hacks● Language features

Page 3: Quines—Programming your way back to where you were

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.

Page 4: Quines—Programming your way back to where you were

Well-known pattern

D

R

Y

Page 5: Quines—Programming your way back to where you were

Well-known pattern

Do

Repeat

Yourself

Page 6: Quines—Programming your way back to where you were

IOCCC 1994: smr

Page 7: Quines—Programming your way back to where you were

IOCCC 1994: smr

(categorized: Worst Abuse of the Rules)

Page 8: Quines—Programming your way back to where you were

The recursive aproach

(live demo)

Page 9: Quines—Programming your way back to where you were

ASCII quine

(live demo)

Page 10: Quines—Programming your way back to where you were

Generic quine

(but it's still ASCII-based)

(live demo)

Page 11: Quines—Programming your way back to where you were

A brief math digression

● Fixed-point theorem● Cool functions to fix

– print source

– interpret

– compile

– gzip source

Page 12: Quines—Programming your way back to where you were

Quines

Page 13: Quines—Programming your way back to where you were

Quines

Page 14: Quines—Programming your way back to where you were

Quines

Page 15: Quines—Programming your way back to where you were

Quine

Page 16: Quines—Programming your way back to where you were

Quine

● “Yields falsehood when preceded by its quotation” yields falsehood when preceded by its quotation.

Page 17: Quines—Programming your way back to where you were

Quine

● “Yields falsehood when preceded by its quotation” yields falsehood when preceded by its quotation.

● quine “hello”.→ hello “hello”.

Page 18: Quines—Programming your way back to where you were

Terminology

● code● data● intron

Page 19: Quines—Programming your way back to where you were

Bootstrapping

Page 20: Quines—Programming your way back to where you were

Multiquines

Page 21: Quines—Programming your way back to where you were

Examples

Page 22: Quines—Programming your way back to where you were

Examples

● (λx.xx) (λx.xx)

Page 23: Quines—Programming your way back to where you were

Examples

● (λx.xx) (λx.xx)● #!/bin/sh

cat $0

Page 24: Quines—Programming your way back to where you were

Examples

● (λx.xx) (λx.xx)● #!/bin/sh

cat $0● #!/bin/cat

Page 25: Quines—Programming your way back to where you were

Examples

● (λx.xx) (λx.xx)● #!/bin/sh

cat $0● #!/bin/cat● puts(s = <<e, s, 'e')

puts(s = <<e, s, 'e')e

Page 26: Quines—Programming your way back to where you were

Examples

● (λx.xx) (λx.xx)● #!/bin/sh

cat $0● #!/bin/cat● puts(s = <<e, s, 'e')

puts(s = <<e, s, 'e')e

● Q

Page 27: Quines—Programming your way back to where you were

Other examples

Page 28: Quines—Programming your way back to where you were

Final thoughts

● incompleteness● trusting trust● Quine Central● backup● introspection● anything else?

Page 29: Quines—Programming your way back to where you were

References

● Wikipedia● David Madore's quine page● C2● Russ Cox's “Zip Files All The Way Down”● Dan Piponi's “Quine Central”


Top Related