A Brief History of the Freedom of Expressions

Preview:

Citation preview

A Brief History of the Freedom of Expressions

Matt Might

http://matt.might.net/

Sapir-Whorf Hypothesis

Language limits

thought.

Edward Sapir Benjamin Whorf

Programming languages

• Where did they come from?

• What kinds of languages do we have now?

• What will they do for us tomorrow?

What is a programming language?

A programming language is a language that can describe a transformation from inputs to outputs...

What is a programming language?

...without ambiguity.

A programming language is a language that can describe a transformation from inputs to outputs...

Origins of programming languages

Origins ofmathematical notation

Euclid’s algorithm (300 BC)

• Greatest common divisor

• GCD(24,18) = 6

• GCD(4,6) = 2

(Probably) Euclid

300 BC

2008 AD

gcd(a, b) = (b == 0) ? a : gcd(b, a mod b)

Limits on the Greeks

• No notation for zero.

• No variables for unknowns.

• No symbols for operations.

• Long division required Ph.D.

• Irrational numbers punished by death.

Example

• The number such that four of its roots is equal to its three of its square.

• 4x = 3x2.

Indian numerals (596)

• Notation for zero.

• Decimal numerals.

• Calculation easier.

Brahmagupta

Solving quadratics (820)

Muhammad ibn Mūsā al-Khwārizmī

Solving quadratics (820)

Muhammad ibn Mūsā al-Khwārizmī

Variables (1570s)

François Viète

Example

• 3 + x is equal to 10 times x2.

• 3 + x = 10x2

Operations (Early 1600s)

William Oughtred

• Letters for variables.

• Symbols for operations.

• Led to slide rule.

Calculus (Late 1600s)

Isaac NewtonPrincipia (1687)

Calculus (Late 1600s)

Gottfried Leibniz

Euler (1700s)

The end of the reign of numbers

Functions

f(x) = x2 + 3

A function transforms an input into an output.

input: x output: f(x)0 3

1 4

2 7

A programming language is a language that can describe a transformation from inputs to outputs.

Functions

A programming language is a language that can describe functions.

Functions

Names for functions

f (x)

Names for functions

f

Names for functions

f (3)

Sets and Logic (1800s)

Giuseppe Peano

• Sets became objects.

• Logic became math.

• Math began unifying.

Sets

A set is a collection of objects.

• {1,2,3} is a set of three numbers.

• {} is the empty set.

• {{1,2,3}} is a set containing a set.

• N is the set of natural numbers.

Frege’s unification

• Logic as foundation.

• Sets as atoms.

• Numbers from sets.

• Functions from sets.

Gottlob Frege

Example

• Every even integer greater than two can be written as the sum of two primes.

• ∀n > 2 : ∃a,b : p(a) ∧ p(b) ∧ a+b = n.

Grundgesetze der Arithmetik

• Published in 1903.

• Foundation for math.

Russell’s postcard

Dear Frege,

Prof. Dr. Gottlob FregeUniversity of GöttingenGöttingen, Germany

{X | X ∉ X} ∈ {X | X ∉ X}

XOXO,Bertrand R.

Russell’s postcard

Dear Frege,

Prof. Dr. Gottlob FregeUniversity of GöttingenGöttingen, Germany

XOXO,Bertrand R.

U FAIL.

Russell’s paradox{X | X ∉ X} ∈ {X | X ∉ X}

Russell’s paradox

Does the set of all sets that do not contain themselves contain itself?

{X | X ∉ X} ∈ {X | X ∉ X}

Russell’s paradox

Does the set of all sets that do not contain themselves contain itself?

{X | X ∉ X} ∈ {X | X ∉ X}

The barber shaves all those that do not shave themselves.

Russell’s paradox

Does the set of all sets that do not contain themselves contain itself?

{X | X ∉ X} ∈ {X | X ∉ X}

The barber shaves all those that do not shave themselves.

But, then who shaves the barber?

Russell’s solution: Orders

• Problem is self-reference.

• Example: This sentence is false.

• Solution: Order sentences.

• Must reference lower orders.

• Seems to avoid paradox.

Bertrand Russell

Functions as foundation?

Alonzo Church

• Notation for functions.

• f(x) = x2

• f(2) = 4

• f = λx.x2

• (λx.x2)(2) = 4

Lambda Calculus (1920s)

Throw away everything in math, except:

x variables

f(e) function application

λx.e function definition

Lambda Calculus

(λx.e) v = {v/x}e.

The Lambda Calculus

• Numbers.

• True and false.

• Propositions.

• Sets.

• Recursive functions.

• Logic.

• ...

Can encode:

Another paradox

k = (λx.¬(x x)) (λx.¬(x x)) = ¬k

Turing machine (1936)

• Student of Church.

• Defined computability.

• Showed λ = computer.

Alan Turing

Modern programming languages

Lisp (1958)

• λ as programming language.

• S-Expression notation.

• Code as data.

• Data as code.

• Self-evaluating.

John McCarthy

Example

(define (factorial x) (if (= x 0) 1 (* n (factorial (- n 1)))))

Kinds of languages

• Declarative: Describes relationship.

• Imperative: Describes process.

Example: Declarative

• A PBJ is the result of placing peanut butter and jelly between two slices of bread.

Example: Imperative

• Place slice of bread on table.

• Add peanut butter.

• Add jelly.

• Place slice of bread on top.

Declarative languages

• Roots in the lambda calculus.

• Examples: Haskell, SML, Lisp/Scheme

• Easy to reason about correctness.

• Generally safe and bug free.

• Can be inefficient.

• Need to think mathematically to use them.

Imperative languages

• Trace roots to Babbage’s engine (1800s).

• Examples: C, C++, Java, Python.

• Hard to know if correct.

• Generally very efficient.

• Extremely dangerous.

45

<exploding-rocket-video />

46

47

48

49

PowerPoint

A fatal exception 0E has occurred at 0137:BFFA21C9. The currentapplication will be terminated.

* Press any key to terminate the current application.* Press CTRL+ALT+DEL again to restart your computer. You will

lose any unsaved information in all applicatons.

Press any key to continue _

<exploding-rocket-video />

51

51

The future of programming languages

Front lines of research

• Get the best of both worlds.

• Write program in both; prove equivalent.

• Use a mixed language: Scala, Ynot.

The future

• Programs won’t crash.

• Programs won’t hang.

• Programs will always do the right thing.

Thank youhttp://matt.might.net/

Example: Numbers

• 0 = λs.λz.z

• n+1 = λs.λz.s(n s z)

Example: True, false, if

• true = λt.λf.t

• false = λt.λf.f

• if = λb.λt.λf.(b t f )

Omega

ω = (λx.x x) (λx.x x) = ω

Fixed-point Combinator

Fix(F) = F(Fix(F))

Fixed points andself reference

• x2 = 1 + x

• x = x2 - 1

• x = F(x), where F = λx.x2 - 1

• x = Fix(F) = ±1

Recursion

• f(n) = if n=0 then 1 else n × f(n-1)

• F(f) = λn.n=0 then 1 else n × f(n-1)

• ! = Fix(F)

Fixed-point Combinator

Fix = λf.(λx.f (x x)) (λx.f (x x))

Recommended