New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia...

118

Transcript of New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia...

Page 1: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics
Page 2: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics
Page 3: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Newton’s Laws of Motion

1. Inertia

2. Acceleration

3. Action-reaction

Page 4: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Force

Mass

Distance

Time

Page 5: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics
Page 6: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics
Page 7: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Aristotelian Physics(excerpt)

Ideal speed

Natural place

Natural motion

Unnatural motion

Page 8: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Why use Functional Programming?

What is Functional Programming?

Page 9: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

A Theory of Functional

Programming

Eric Normand

LambdUp December 6, 2017

Page 10: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

New Orleans February 15 & 16, 2018

clojuresync.com

10% off: LAMBDUP

Page 11: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

paradigm

a philosophical and theoretical framework of a scientific school or discipline within which theories, laws, and generalizations and the experiments performed in support of them are formulated

Merriam-Webster

Page 12: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

philosophical or theoretical framework,

world view

Page 13: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

theories, laws, generalizations

Page 14: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

basic assumptions, ways of thinking, methodology

Page 15: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Why use Functional Programming?

What is Functional Programming?

Page 16: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Goals of my Theory

Page 17: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Goals of my Theory• Explain what it is we (functional programmers) actually do

Page 18: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Goals of my Theory• Explain what it is we (functional programmers) actually do

• in terms we can all understand

Page 19: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Goals of my Theory• Explain what it is we (functional programmers) actually do

• in terms we can all understand

• Explain why it has advantages over other paradigms

Page 20: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Goals of my Theory• Explain what it is we (functional programmers) actually do

• in terms we can all understand

• Explain why it has advantages over other paradigms

• to people who haven’t done FP

Page 21: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Goals of my Theory• Explain what it is we (functional programmers) actually do

• in terms we can all understand

• Explain why it has advantages over other paradigms

• to people who haven’t done FP

• Avoid focusing on features

Page 22: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Goals of my Theory• Explain what it is we (functional programmers) actually do

• in terms we can all understand

• Explain why it has advantages over other paradigms

• to people who haven’t done FP

• Avoid focusing on features

• Give explanatory and predictive power

Page 23: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Goals of my Theory• Explain what it is we (functional programmers) actually do

• in terms we can all understand

• Explain why it has advantages over other paradigms

• to people who haven’t done FP

• Avoid focusing on features

• Give explanatory and predictive power

• Self-described functional programmers should agree

Page 24: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

My Theory of FP

Page 25: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

My Theory of FP

Actions

Page 26: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

My Theory of FP

Actions Data

Page 27: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

My Theory of FP

Actions Data Calculations

Page 28: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions

Page 29: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actionsthe process of doing something, typically to achieve an aim

Page 30: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actionsthe process of doing something, typically to achieve an aim

• Typically called Effects or Side-effects

Page 31: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actionsthe process of doing something, typically to achieve an aim

• Typically called Effects or Side-effects

• Depend on when you run them or how many times you run them

Page 32: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actionsthe process of doing something, typically to achieve an aim

• Typically called Effects or Side-effects

• Depend on when you run them or how many times you run them

• Examples

Page 33: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actionsthe process of doing something, typically to achieve an aim

• Typically called Effects or Side-effects

• Depend on when you run them or how many times you run them

• Examples

• Sending a message over the network

Page 34: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actionsthe process of doing something, typically to achieve an aim

• Typically called Effects or Side-effects

• Depend on when you run them or how many times you run them

• Examples

• Sending a message over the network

• Writing to file system — other programs can see the change

Page 35: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actionsthe process of doing something, typically to achieve an aim

• Typically called Effects or Side-effects

• Depend on when you run them or how many times you run them

• Examples

• Sending a message over the network

• Writing to file system — other programs can see the change

• Changing or reading mutable state

Page 36: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Data

Page 37: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Datafactual information used as a basis for reasoning, discussion, or calculation

Page 38: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Datafactual information used as a basis for reasoning, discussion, or calculation

• Inert

Page 39: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Datafactual information used as a basis for reasoning, discussion, or calculation

• Inert

• Serializable

Page 40: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Datafactual information used as a basis for reasoning, discussion, or calculation

• Inert

• Serializable

• Requiring interpretation

Page 41: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Datafactual information used as a basis for reasoning, discussion, or calculation

• Inert

• Serializable

• Requiring interpretation

• Examples

Page 42: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Datafactual information used as a basis for reasoning, discussion, or calculation

• Inert

• Serializable

• Requiring interpretation

• Examples

• Numbers

Page 43: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Datafactual information used as a basis for reasoning, discussion, or calculation

• Inert

• Serializable

• Requiring interpretation

• Examples

• Numbers

• Bytes

Page 44: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Datafactual information used as a basis for reasoning, discussion, or calculation

• Inert

• Serializable

• Requiring interpretation

• Examples

• Numbers

• Bytes

• Strings

Page 45: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Datafactual information used as a basis for reasoning, discussion, or calculation

• Inert

• Serializable

• Requiring interpretation

• Examples

• Numbers

• Bytes

• Strings

• Collections

Page 46: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculations

Page 47: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculationscomputation from inputs to outputs

Page 48: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculationscomputation from inputs to outputs

• Mathematical functions

Page 49: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculationscomputation from inputs to outputs

• Mathematical functions

• Eternal — outside of time

Page 50: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculationscomputation from inputs to outputs

• Mathematical functions

• Eternal — outside of time

• Referentially transparent

Page 51: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculationscomputation from inputs to outputs

• Mathematical functions

• Eternal — outside of time

• Referentially transparent

• Examples

Page 52: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculationscomputation from inputs to outputs

• Mathematical functions

• Eternal — outside of time

• Referentially transparent

• Examples

• List concatenation

Page 53: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculationscomputation from inputs to outputs

• Mathematical functions

• Eternal — outside of time

• Referentially transparent

• Examples

• List concatenation

• Summing numbers

Page 54: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Contrast with OOP

Page 55: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

OOP

Page 56: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

OOP

Objects

Page 57: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

OOP

Objects References

Page 58: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

OOP

Objects References Messages

Page 59: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

ImplementationHaskell

• Data — built-in types and defined types

• Calculations — functions

• Actions — IO type

Page 60: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

ImplementationClojure

• Data — built-in types

• Calculations — pure functions

• Actions — impure functions

Page 61: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Further down the rabbit hole

• Everything “First-class”

• Data

• Calculations

• Actions

• Minimum necessary to program functionally in a language

Page 62: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separate

Page 63: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Page 64: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Data + Data => Data

Page 65: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Data + Data => Data

Examples

Page 66: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Data + Data => Data

Examples

• Addition

Page 67: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Data + Data => Data

Examples

• Addition

• Concatenation

Page 68: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Data + Data => Data

Examples

• Addition

• Concatenation

Calculations

Page 69: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Data + Data => Data

Examples

• Addition

• Concatenation

Calculations

Calc + Calc => Calc

Page 70: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Data + Data => Data

Examples

• Addition

• Concatenation

Calculations

Calc + Calc => Calc

Examples

Page 71: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Data + Data => Data

Examples

• Addition

• Concatenation

Calculations

Calc + Calc => Calc

Examples

• compose

Page 72: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Data + Data => Data

Examples

• Addition

• Concatenation

Calculations

Calc + Calc => Calc

Examples

• compose

• juxtapose

Page 73: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Data + Data => Data

Examples

• Addition

• Concatenation

Calculations

Calc + Calc => Calc

Examples

• compose

• juxtapose

Actions

Page 74: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Data + Data => Data

Examples

• Addition

• Concatenation

Calculations

Calc + Calc => Calc

Examples

• compose

• juxtapose

Actions

Actn + Actn => Actn

Page 75: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Data + Data => Data

Examples

• Addition

• Concatenation

Calculations

Calc + Calc => Calc

Examples

• compose

• juxtapose

Actions

Actn + Actn => Actn

Examples

Page 76: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Data + Data => Data

Examples

• Addition

• Concatenation

Calculations

Calc + Calc => Calc

Examples

• compose

• juxtapose

Actions

Actn + Actn => Actn

Examples

• in sequence

Page 77: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Domains are separateData

Data + Data => Data

Examples

• Addition

• Concatenation

Calculations

Calc + Calc => Calc

Examples

• compose

• juxtapose

Actions

Actn + Actn => Actn

Examples

• in sequence

• in parallel

Page 78: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions

Page 79: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions• Contagious!

Page 80: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions• Contagious!

• Calculation + Action => Action

Page 81: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions• Contagious!

• Calculation + Action => Action

• Data + Action => Action

Page 82: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions• Contagious!

• Calculation + Action => Action

• Data + Action => Action

• Examples

Page 83: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions• Contagious!

• Calculation + Action => Action

• Data + Action => Action

• Examples

• Print the square of a number — square => print!

Page 84: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions• Contagious!

• Calculation + Action => Action

• Data + Action => Action

• Examples

• Print the square of a number — square => print!

• Parse the input as a number — read! => parse

Page 85: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculations

Page 86: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculations• Algebraic manipulation

Page 87: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculations• Algebraic manipulation

• Turing complete

Page 88: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculations• Algebraic manipulation

• Turing complete

• implies the Halting problem

Page 89: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculations• Algebraic manipulation

• Turing complete

• implies the Halting problem

• Opaque

Page 90: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculations• Algebraic manipulation

• Turing complete

• implies the Halting problem

• Opaque

• What is this code going to do?

Page 91: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Calculations• Algebraic manipulation

• Turing complete

• implies the Halting problem

• Opaque

• What is this code going to do?

• Only way to know is to run it

Page 92: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Data

• Can represent something else

• Structure

• Known Big-O complexities

Page 93: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

RefactoringsActions

• Action => Action + Calculation

• Action => Action + Data

• Action => Action + Action

Calculations

• Calculation => Calculation + Data

• Calculation => Calculation + Calculation

Page 94: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions are universal

Actions

Calculations

Data

Page 95: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

What counts as an Action?

Calculations

Timeless

Actions

Bound in time

Page 96: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

What counts as an Action?

Calculations

Timeless

Actions

Bound in time

Pure function

Page 97: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

What counts as an Action?

Calculations

Timeless

Actions

Bound in time

Pure function Read/write to disk

Page 98: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

What counts as an Action?

Calculations

Timeless

Actions

Bound in time

Pure function Read/write to disk

Pure function

Page 99: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

What counts as an Action?

Calculations

Timeless

Actions

Bound in time

Pure function Read/write to disk

Pure functiontakes 24 hours to compute

Page 100: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

What counts as an Action?

Calculations

Timeless

Actions

Bound in time

Pure function Read/write to disk

Pure functiontakes 24 hours to compute

Page 101: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

What counts as an Action?

Calculations

Timeless

Actions

Bound in time

Pure function Read/write to disk

Pure functiontakes 24 hours to compute

Read/write to temp file as buffer

Page 102: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

What counts as an Action?

Calculations

Timeless

Actions

Bound in time

Pure function Read/write to disk

Pure functiontakes 24 hours to compute

Read/write to temp file as buffer

Page 103: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions how many times they run

Page 104: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions how many times they run

always matters - 0≠1≠more

Page 105: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions how many times they run

always matters - 0≠1≠morelaunching a missile

Page 106: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions how many times they run

always matters - 0≠1≠morelaunching a missilesending an email

Page 107: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions how many times they run

always matters - 0≠1≠morelaunching a missilesending an email

idempotent - 0≠1=more

Page 108: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions how many times they run

always matters - 0≠1≠morelaunching a missilesending an email

idempotent - 0≠1=moresetting public flag to true

Page 109: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions how many times they run

always matters - 0≠1≠morelaunching a missilesending an email

idempotent - 0≠1=moresetting public flag to true

free of side-effects - 0=1=more

Page 110: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions how many times they run

always matters - 0≠1≠morelaunching a missilesending an email

idempotent - 0≠1=moresetting public flag to true

free of side-effects - 0=1=moreGET request

Page 111: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions how many times they run

always matters - 0≠1≠morelaunching a missilesending an email

idempotent - 0≠1=moresetting public flag to true

free of side-effects - 0=1=moreGET request

reading mutable state

Page 112: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions when they run

Page 113: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions when they run

transactional read

Page 114: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions when they run

transactional readguaranteed to be consistent

Page 115: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions when they run

transactional readguaranteed to be consistent

transactional+serialized writes

Page 116: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions when they run

transactional readguaranteed to be consistent

transactional+serialized writesOrder matters, but at least it’s some order

Page 117: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions when they run

transactional readguaranteed to be consistent

transactional+serialized writesOrder matters, but at least it’s some order

exactly once reads

Page 118: New Newton’s Laws of Motion - LispCast · 2018. 2. 26. · Newton’s Laws of Motion 1. Inertia 2. Acceleration 3. Action-reaction. Force Mass Distance Time. Aristotelian Physics

Actions when they run

transactional readguaranteed to be consistent

transactional+serialized writesOrder matters, but at least it’s some order

exactly once readsCommunicating Sequential Processes