SlideShare ist ein Scribd-Unternehmen logo
1 von 78
IMPOSSIBLE
PROGRAMS
@tomstuart / QCon London / 2014-03-05
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Watch the video with slide
synchronization on InfoQ.com!
http://www.infoq.com/presentations
/programming-limitations
Presented at QCon London
www.qconlondon.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
CAN’T
DO
PROGRAMS
EVERYTHING
how can a
PROGRAM
be
IMPOSSIBLE?
WE DEMAND
UNIVERSAL SYSTEMS
Compare two programming languages,
say Python and Ruby.
We can translate any Python program into Ruby.
We can translate any Ruby program into Python.
We can implement a Python interpreter in Ruby.
We can implement a Ruby interpreter in Python.
We can implement a Python interpreter in JavaScript.
We can implement a JavaScript interpreter in Python.
We can implement a Turing machine simulator in Ruby.
We can implement Ruby as a Turing machine.
JavaScript
Ruby
Python
Lambda calculus Turing machines
SKI calculus
Tag systems
Partial recursive
functions
Game of Life
Rule 110
C++ Haskell
Lisp Register machines
Magic: The
Gathering
C
Java
XSLT
Universal systems can run software.
We don’t just want machines, we want
general-purpose machines.
PROGRAMS ARE DATA
>> puts 'hello world'
hello world
=> nil
>> program = "puts 'hello world'"
=> "puts 'hello world'"
>> bytes_in_binary = program.bytes.
map { |byte| byte.to_s(2).rjust(8, '0') }
=> ["01110000", "01110101", "01110100", "01110011", "00100000",
"00100111", "01101000", "01100101", "01101100", "01101100",
"01101111", "00100000", "01110111", "01101111", "01110010",
"01101100", "01100100", "00100111"]
>> number = bytes_in_binary.join.to_i(2)
=> 9796543849500706521102980495717740021834791
>> number = 9796543849500706521102980495717740021834791
=> 9796543849500706521102980495717740021834791
>> bytes_in_binary = number.to_s(2).scan(/.+?(?=.{8}*z)/)
=> [ "1110000", "01110101", "01110100", "01110011", "00100000",
"00100111", "01101000", "01100101", "01101100", "01101100",
"01101111", "00100000", "01110111", "01101111", "01110010",
"01101100", "01100100", "00100111"]
>> program = bytes_in_binary.map { |string| string.to_i(2).chr }.join
=> "puts 'hello world'"
>> eval program
hello world
=> nil
UNIVERSAL SYSTEMS
+PROGRAMS ARE DATA
=INFINITE LOOPS
Every universal system can simulate every other
universal system, including itself.
More specifically: every universal programming
language can implement its own interpreter.
def evaluate(program, input)
# parse program
# evaluate program on input while capturing output
# return output
end
>> evaluate('print $stdin.read.reverse', 'hello world')
=> "dlrow olleh"
def evaluate(program, input)
# parse program
# evaluate program on input while capturing output
# return output
end
def evaluate_on_itself(program)
evaluate(program, program)
end
>> evaluate_on_itself('print $stdin.read.reverse')
=> "esrever.daer.nidts$ tnirp"
def evaluate(program, input)
# parse program
# evaluate program on input while capturing output
# return output
end
def evaluate_on_itself(program)
evaluate(program, program)
end
program = $stdin.read
if evaluate_on_itself(program) == 'no'
print 'yes'
else
print 'no'
end
does_it_say_no.rb
$ echo 'print $stdin.read.reverse' | ruby does_it_say_no.rb
no
$ echo 'print "no" if $stdin.read.include?("no")' | ruby does_it_say_no.rb
yes
$ ruby does_it_say_no.rb < does_it_say_no.rb
???
does_it_say_no.rb
yes
no
never finish
other output?
does_it_say_no.rb
✘ ✔✘ ✘
Ruby is universal
so we can write #evaluate in it
so we can construct a special program that loops forever
so here's one
PROGRAM
IMPOSSIBLE
Sometimes infinite loops are bad.
We could remove features from a language
until there’s no way to cause an infinite loop.
remove while loops etc, only allow iteration
over finite data structures
to prevent (λx.x x)(λx.x x)
e.g. only allow a method to call other methods
whose names come later in the alphabet
• No unlimited iteration
• No lambdas
• No recursive method calls
• No blocking I/O
• ...
The result is called a total
programming language.
It must be impossible to write
an interpreter for a total
language in itself.
if we could write #evaluate in a total language
so it must be impossible to write #evaluate in one
then we could use it to construct a special program
that loops forever
but a total language doesn’t let you write programs
that loop forever
(That’s weird, because a total language’s
interpreter always finishes eventually, so
it feels like the kind of program we
should be able to write.)
We could write an interpreter for a total language
in a universal language, or in some other more
powerful total language.
ABOUT
REALITY?
WHAT
okay but
#evaluate is an impossible program for any
total language, which means that total
languages can’t be universal.
Universal systems have impossible programs too.
input = $stdin.read
puts input.upcase
This program always finishes.*
* assuming STDIN is finite & nonblocking
input = $stdin.read
while true
# do nothing
end
puts input.upcase
This program always loops forever.
Can we write a program that can
decide this in general?
(This question is called the halting problem.)
input = $stdin.read
output = ''
n = input.length
until n.zero?
output = output + '*'
n = n - 1
end
puts output
require 'prime'
def primes_less_than(n)
Prime.each(n - 1).entries
end
def sum_of_two_primes?(n)
primes = primes_less_than(n)
primes.any? { |a| primes.any? { |b| a + b == n } }
end
n = 4
while sum_of_two_primes?(n)
n = n + 2
end
print n
def halts?(program, input)
# parse program
# analyze program
# return true if program halts on input, false if not
end
>> halts?('print $stdin.read', 'hello world')
=> true
>> halts?('while true do end', 'hello world')
=> false
def halts?(program, input)
# parse program
# analyze program
# return true if program halts on input, false if not
end
def halts_on_itself?(program)
halts?(program, program)
end
program = $stdin.read
if halts_on_itself?(program)
while true
# do nothing
end
end
do_the_opposite.rb
$ ruby do_the_opposite.rb < do_the_opposite.rb
do_the_opposite.rb
eventually finish loop forever
do_the_opposite.rb
✘ ✘
Every real program must either loop forever
or not, but whichever happens, #halts?
will be wrong about it.
do_the_opposite.rb forces #halts? to
give the wrong answer.
if we could write #halts?
so it must be impossible to write #halts?
then we could use it to construct a special program
that forces #halts? to give the wrong answer
but a correct implementation of #halts?
would always give the right answer
WHO
CARES?
okay but
We never actually want to ask a computer
whether a program will loop forever.
But we often want to ask computers
other questions about programs.
def prints_hello_world?(program, input)
# parse program
# analyze program
# return true if program prints "hello world", false if not
end
>> prints_hello_world?('print $stdin.read.reverse', 'dlrow olleh')
=> true
>> prints_hello_world?('print $stdin.read.upcase', 'dlrow olleh')
=> false
def prints_hello_world?(program, input)
# parse program
# analyze program
# return true if program prints "hello world", false if not
end
def halts?(program, input)
hello_world_program = %Q{
program = #{program.inspect}
input = $stdin.read
evaluate(program, input)
print 'hello world'
}
prints_hello_world?(hello_world_program, input)
end
if we could write #prints_hello_world?
so it must be impossible to write
#prints_hello_world?
then we could use it to construct a correct
implementation of #halts?
but it’s impossible to correctly implement #halts?
Not only can we not ask
“does this program halt?”,
we also can’t ask
“does this program do
what I want it to do?”.
This is Rice’s theorem:
Any interesting property
of program behavior
is undecidable.
WHY
HAPPEN?
DOES
THIS
We can’t look into the future and predict
what a program will do.
The only way to find out for sure is to run it.
But when we run a program, we don’t know
how long we have to wait for it to finish.
(Some programs never will.)
Any system with enough power to be self-referential
can’t correctly answer every question about itself.
We need to step outside the self-referential system
and use a different, more powerful system to answer
questions about it.
But there is no more powerful system to upgrade to.
HOW
COPE?
CAN WE
• Ask undecidable questions, but give up if an
answer can’t be found in a reasonable time.
• Ask several small questions whose answers
provide evidence for the answer to a larger
question.
• Ask decidable questions by being conservative.
• Approximate a program by converting it into
something simpler, then ask questions about the
approximation.
StuartUnderstandingComputation
From Simple Machines to Impossible Programs
Tom Stuart
Understanding
Computation
eilly.com
tter: @oreillymedia
ebook.com/oreilly
m Stuart, a computer
entist and programmer,
he founder of Codon, a
gital product consultancy
London. He works as a
nsultant, mentor, and
iner, helping companies
improve the quality and
rity of their approach to
eating software products.
From Simple Machines to Impossible Programs
Tom Stuart
Understanding
Computation
THE END
QCON(50% off ebook, 40% off print)
http://computationbook.com/
@tomstuart / tom@codon.com
Watch the video with slide synchronization on
InfoQ.com!
http://www.infoq.com/presentations/programming
-limitations

Weitere ähnliche Inhalte

Ähnlich wie Impossible Programs

Jr devsurvivalguide
Jr devsurvivalguideJr devsurvivalguide
Jr devsurvivalguideJames York
 
Mobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B ExperimentsMobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B Experimentslacyrhoades
 
The Ring programming language version 1.3 book - Part 81 of 88
The Ring programming language version 1.3 book - Part 81 of 88The Ring programming language version 1.3 book - Part 81 of 88
The Ring programming language version 1.3 book - Part 81 of 88Mahmoud Samir Fayed
 
C# .NET - Um overview da linguagem
C# .NET - Um overview da linguagem C# .NET - Um overview da linguagem
C# .NET - Um overview da linguagem Claudson Oliveira
 
Generative Testing in Clojure
Generative Testing in ClojureGenerative Testing in Clojure
Generative Testing in ClojureAlistair Roche
 
Gearman and CodeIgniter
Gearman and CodeIgniterGearman and CodeIgniter
Gearman and CodeIgniterErik Giberti
 
Reactive programming with RxJS - Taiwan
Reactive programming with RxJS - TaiwanReactive programming with RxJS - Taiwan
Reactive programming with RxJS - Taiwanmodernweb
 
Speaking 'Development Language' (Or, how to get your hands dirty with technic...
Speaking 'Development Language' (Or, how to get your hands dirty with technic...Speaking 'Development Language' (Or, how to get your hands dirty with technic...
Speaking 'Development Language' (Or, how to get your hands dirty with technic...Julie Meloni
 
Responsive, adaptive and responsible - keynote at NebraskaJS
Responsive, adaptive and responsible - keynote at NebraskaJSResponsive, adaptive and responsible - keynote at NebraskaJS
Responsive, adaptive and responsible - keynote at NebraskaJSChristian Heilmann
 
iOS Development at Scale @Chegg
iOS Development at Scale @CheggiOS Development at Scale @Chegg
iOS Development at Scale @CheggGalOrlanczyk
 
Python Programming - III. Controlling the Flow
Python Programming - III. Controlling the FlowPython Programming - III. Controlling the Flow
Python Programming - III. Controlling the FlowRanel Padon
 
Work Queues
Work QueuesWork Queues
Work Queuesciconf
 
The Ring programming language version 1.6 book - Part 181 of 189
The Ring programming language version 1.6 book - Part 181 of 189The Ring programming language version 1.6 book - Part 181 of 189
The Ring programming language version 1.6 book - Part 181 of 189Mahmoud Samir Fayed
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basicSara Samol
 
Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014Robert Reiz
 
Webdev and programming
Webdev and programming  Webdev and programming
Webdev and programming George Ingram
 

Ähnlich wie Impossible Programs (20)

Jr devsurvivalguide
Jr devsurvivalguideJr devsurvivalguide
Jr devsurvivalguide
 
Mobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B ExperimentsMobile App Feature Configuration and A/B Experiments
Mobile App Feature Configuration and A/B Experiments
 
The Ring programming language version 1.3 book - Part 81 of 88
The Ring programming language version 1.3 book - Part 81 of 88The Ring programming language version 1.3 book - Part 81 of 88
The Ring programming language version 1.3 book - Part 81 of 88
 
ForLoops.pptx
ForLoops.pptxForLoops.pptx
ForLoops.pptx
 
C# .NET - Um overview da linguagem
C# .NET - Um overview da linguagem C# .NET - Um overview da linguagem
C# .NET - Um overview da linguagem
 
Generative Testing in Clojure
Generative Testing in ClojureGenerative Testing in Clojure
Generative Testing in Clojure
 
Gearman and CodeIgniter
Gearman and CodeIgniterGearman and CodeIgniter
Gearman and CodeIgniter
 
Reactive programming with RxJS - Taiwan
Reactive programming with RxJS - TaiwanReactive programming with RxJS - Taiwan
Reactive programming with RxJS - Taiwan
 
Js basics
Js basicsJs basics
Js basics
 
Speaking 'Development Language' (Or, how to get your hands dirty with technic...
Speaking 'Development Language' (Or, how to get your hands dirty with technic...Speaking 'Development Language' (Or, how to get your hands dirty with technic...
Speaking 'Development Language' (Or, how to get your hands dirty with technic...
 
Home Automation System
Home Automation SystemHome Automation System
Home Automation System
 
Responsive, adaptive and responsible - keynote at NebraskaJS
Responsive, adaptive and responsible - keynote at NebraskaJSResponsive, adaptive and responsible - keynote at NebraskaJS
Responsive, adaptive and responsible - keynote at NebraskaJS
 
iOS Development at Scale @Chegg
iOS Development at Scale @CheggiOS Development at Scale @Chegg
iOS Development at Scale @Chegg
 
Python Programming - III. Controlling the Flow
Python Programming - III. Controlling the FlowPython Programming - III. Controlling the Flow
Python Programming - III. Controlling the Flow
 
Work Queues
Work QueuesWork Queues
Work Queues
 
The Ring programming language version 1.6 book - Part 181 of 189
The Ring programming language version 1.6 book - Part 181 of 189The Ring programming language version 1.6 book - Part 181 of 189
The Ring programming language version 1.6 book - Part 181 of 189
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basic
 
Introducing Small Basic.pdf
Introducing Small Basic.pdfIntroducing Small Basic.pdf
Introducing Small Basic.pdf
 
Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014Continuous Updating with VersionEye at code.talks 2014
Continuous Updating with VersionEye at code.talks 2014
 
Webdev and programming
Webdev and programming  Webdev and programming
Webdev and programming
 

Mehr von C4Media

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoC4Media
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileC4Media
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020C4Media
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsC4Media
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No KeeperC4Media
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like OwnersC4Media
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaC4Media
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideC4Media
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDC4Media
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine LearningC4Media
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at SpeedC4Media
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsC4Media
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsC4Media
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerC4Media
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleC4Media
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeC4Media
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereC4Media
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing ForC4Media
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data EngineeringC4Media
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreC4Media
 

Mehr von C4Media (20)

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy Mobile
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No Keeper
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like Owners
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 

Kürzlich hochgeladen

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 

Impossible Programs

  • 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /programming-limitations
  • 3. Presented at QCon London www.qconlondon.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  • 7. Compare two programming languages, say Python and Ruby.
  • 8. We can translate any Python program into Ruby. We can translate any Ruby program into Python. We can implement a Python interpreter in Ruby. We can implement a Ruby interpreter in Python. We can implement a Python interpreter in JavaScript. We can implement a JavaScript interpreter in Python. We can implement a Turing machine simulator in Ruby. We can implement Ruby as a Turing machine.
  • 9. JavaScript Ruby Python Lambda calculus Turing machines SKI calculus Tag systems Partial recursive functions Game of Life Rule 110 C++ Haskell Lisp Register machines Magic: The Gathering C Java XSLT
  • 10. Universal systems can run software. We don’t just want machines, we want general-purpose machines.
  • 12. >> puts 'hello world' hello world => nil >> program = "puts 'hello world'" => "puts 'hello world'" >> bytes_in_binary = program.bytes. map { |byte| byte.to_s(2).rjust(8, '0') } => ["01110000", "01110101", "01110100", "01110011", "00100000", "00100111", "01101000", "01100101", "01101100", "01101100", "01101111", "00100000", "01110111", "01101111", "01110010", "01101100", "01100100", "00100111"] >> number = bytes_in_binary.join.to_i(2) => 9796543849500706521102980495717740021834791
  • 13. >> number = 9796543849500706521102980495717740021834791 => 9796543849500706521102980495717740021834791 >> bytes_in_binary = number.to_s(2).scan(/.+?(?=.{8}*z)/) => [ "1110000", "01110101", "01110100", "01110011", "00100000", "00100111", "01101000", "01100101", "01101100", "01101100", "01101111", "00100000", "01110111", "01101111", "01110010", "01101100", "01100100", "00100111"] >> program = bytes_in_binary.map { |string| string.to_i(2).chr }.join => "puts 'hello world'" >> eval program hello world => nil
  • 14. UNIVERSAL SYSTEMS +PROGRAMS ARE DATA =INFINITE LOOPS
  • 15. Every universal system can simulate every other universal system, including itself. More specifically: every universal programming language can implement its own interpreter.
  • 16. def evaluate(program, input) # parse program # evaluate program on input while capturing output # return output end
  • 17. >> evaluate('print $stdin.read.reverse', 'hello world') => "dlrow olleh"
  • 18. def evaluate(program, input) # parse program # evaluate program on input while capturing output # return output end def evaluate_on_itself(program) evaluate(program, program) end
  • 20. def evaluate(program, input) # parse program # evaluate program on input while capturing output # return output end def evaluate_on_itself(program) evaluate(program, program) end program = $stdin.read if evaluate_on_itself(program) == 'no' print 'yes' else print 'no' end does_it_say_no.rb
  • 21. $ echo 'print $stdin.read.reverse' | ruby does_it_say_no.rb no $ echo 'print "no" if $stdin.read.include?("no")' | ruby does_it_say_no.rb yes $ ruby does_it_say_no.rb < does_it_say_no.rb ???
  • 23. Ruby is universal so we can write #evaluate in it so we can construct a special program that loops forever
  • 25. Sometimes infinite loops are bad. We could remove features from a language until there’s no way to cause an infinite loop.
  • 26. remove while loops etc, only allow iteration over finite data structures to prevent (λx.x x)(λx.x x) e.g. only allow a method to call other methods whose names come later in the alphabet • No unlimited iteration • No lambdas • No recursive method calls • No blocking I/O • ...
  • 27. The result is called a total programming language. It must be impossible to write an interpreter for a total language in itself.
  • 28. if we could write #evaluate in a total language so it must be impossible to write #evaluate in one then we could use it to construct a special program that loops forever but a total language doesn’t let you write programs that loop forever
  • 29. (That’s weird, because a total language’s interpreter always finishes eventually, so it feels like the kind of program we should be able to write.)
  • 30. We could write an interpreter for a total language in a universal language, or in some other more powerful total language.
  • 32. #evaluate is an impossible program for any total language, which means that total languages can’t be universal. Universal systems have impossible programs too.
  • 33. input = $stdin.read puts input.upcase This program always finishes.* * assuming STDIN is finite & nonblocking
  • 34. input = $stdin.read while true # do nothing end puts input.upcase This program always loops forever.
  • 35. Can we write a program that can decide this in general? (This question is called the halting problem.)
  • 36. input = $stdin.read output = '' n = input.length until n.zero? output = output + '*' n = n - 1 end puts output
  • 37. require 'prime' def primes_less_than(n) Prime.each(n - 1).entries end def sum_of_two_primes?(n) primes = primes_less_than(n) primes.any? { |a| primes.any? { |b| a + b == n } } end n = 4 while sum_of_two_primes?(n) n = n + 2 end print n
  • 38. def halts?(program, input) # parse program # analyze program # return true if program halts on input, false if not end
  • 39. >> halts?('print $stdin.read', 'hello world') => true >> halts?('while true do end', 'hello world') => false
  • 40. def halts?(program, input) # parse program # analyze program # return true if program halts on input, false if not end def halts_on_itself?(program) halts?(program, program) end program = $stdin.read if halts_on_itself?(program) while true # do nothing end end do_the_opposite.rb
  • 41. $ ruby do_the_opposite.rb < do_the_opposite.rb
  • 42. do_the_opposite.rb eventually finish loop forever do_the_opposite.rb ✘ ✘
  • 43. Every real program must either loop forever or not, but whichever happens, #halts? will be wrong about it. do_the_opposite.rb forces #halts? to give the wrong answer.
  • 44. if we could write #halts? so it must be impossible to write #halts? then we could use it to construct a special program that forces #halts? to give the wrong answer but a correct implementation of #halts? would always give the right answer
  • 46. We never actually want to ask a computer whether a program will loop forever. But we often want to ask computers other questions about programs.
  • 47. def prints_hello_world?(program, input) # parse program # analyze program # return true if program prints "hello world", false if not end
  • 48. >> prints_hello_world?('print $stdin.read.reverse', 'dlrow olleh') => true >> prints_hello_world?('print $stdin.read.upcase', 'dlrow olleh') => false
  • 49. def prints_hello_world?(program, input) # parse program # analyze program # return true if program prints "hello world", false if not end def halts?(program, input) hello_world_program = %Q{ program = #{program.inspect} input = $stdin.read evaluate(program, input) print 'hello world' } prints_hello_world?(hello_world_program, input) end
  • 50. if we could write #prints_hello_world? so it must be impossible to write #prints_hello_world? then we could use it to construct a correct implementation of #halts? but it’s impossible to correctly implement #halts?
  • 51. Not only can we not ask “does this program halt?”, we also can’t ask “does this program do what I want it to do?”.
  • 52. This is Rice’s theorem: Any interesting property of program behavior is undecidable.
  • 54. We can’t look into the future and predict what a program will do. The only way to find out for sure is to run it. But when we run a program, we don’t know how long we have to wait for it to finish. (Some programs never will.)
  • 55. Any system with enough power to be self-referential can’t correctly answer every question about itself. We need to step outside the self-referential system and use a different, more powerful system to answer questions about it. But there is no more powerful system to upgrade to.
  • 57. • Ask undecidable questions, but give up if an answer can’t be found in a reasonable time. • Ask several small questions whose answers provide evidence for the answer to a larger question. • Ask decidable questions by being conservative. • Approximate a program by converting it into something simpler, then ask questions about the approximation.
  • 58. StuartUnderstandingComputation From Simple Machines to Impossible Programs Tom Stuart Understanding Computation eilly.com tter: @oreillymedia ebook.com/oreilly m Stuart, a computer entist and programmer, he founder of Codon, a gital product consultancy London. He works as a nsultant, mentor, and iner, helping companies improve the quality and rity of their approach to eating software products.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77. From Simple Machines to Impossible Programs Tom Stuart Understanding Computation THE END QCON(50% off ebook, 40% off print) http://computationbook.com/ @tomstuart / tom@codon.com
  • 78. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations/programming -limitations