Top Banner
Hitchhiker's Guide to Functional Programming
15

Hitchhiker's Guide to Functional Programming

Jan 20, 2017

Download

Technology

Sergey Shishkin
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 2: Hitchhiker's Guide to Functional Programming

Significantly trivialized history of computing

Page 3: Hitchhiker's Guide to Functional Programming

Alonzo ChurchResearched decidability of algorithms and invented a

generic model of calculation – the λ-calculus (early 1930s*)

*see https://en.wikipedia.org/wiki/Lambda_calculus

Page 4: Hitchhiker's Guide to Functional Programming

Alan TuringCreated a model of a generic

computer – the Universal Turing machine (ca. 1936*)

*see https://en.wikipedia.org/wiki/Turing_machine

Page 5: Hitchhiker's Guide to Functional Programming

John von Neumann

Created the architecture of modern computers based on the Universal Turing machine (early 1940s*)

*see https://en.wikipedia.org/wiki/Von_Neumann_architecture

Page 6: Hitchhiker's Guide to Functional Programming

And PL features exploded...GOTO, mutation, pointers, null refs, exceptions, floating point numbers, inheritance, interfaces, threads…

See http://blog.ploeh.dk/2015/04/13/less-is-more-language-features/ for a discussion of harmful PL features

Page 7: Hitchhiker's Guide to Functional Programming

John McCarthyCreated Lisp language based on

the λ-calculus and featuring macros (ca. 1958*)

*see http://www-formal.stanford.edu/jmc/history/lisp/lisp.html

Page 8: Hitchhiker's Guide to Functional Programming

Edsger DijkstraMade a case against the

GOTO statement (in 1968*)*see https://en.wikipedia.org/wiki/Edsger_W._Dijkstra

Page 9: Hitchhiker's Guide to Functional Programming

A case against mutationIt’s about time to ban the next offender

Page 10: Hitchhiker's Guide to Functional Programming

What’s wrong with this code?

int sum = 0;

for (int i = 1; i <= 10; i++) {

if (i % 2 == 0) sum += i * i;}

System.out.println(sum);

Page 11: Hitchhiker's Guide to Functional Programming

Refactoring exercise

Page 12: Hitchhiker's Guide to Functional Programming

Erik Meijer

Recursion is GOTO of functional programming

Page 13: Hitchhiker's Guide to Functional Programming

● λ-Calculus is a model of computation● Program is data, generic evaluation algorithm

● Turing machine is a model of a computer

● Program is algorithm

Turing machine and λ-calculus are proven equivalent in terms of computability

Summary