Slide 1

Slide 1 text

THE SCIENTIST ANDREW GODWIN // @andrewgodwin THE ENGINEER AND

Slide 2

Slide 2 text

Hi, I’m Andrew Godwin

Slide 3

Slide 3 text

I call myself an "engineer"

Slide 4

Slide 4 text

But I studied Computer Science

Slide 5

Slide 5 text

I knew programming going in. But this was different.

Slide 6

Slide 6 text

“ Edsger Dijkstra Computer science is no more about computers than astronomy is about telescopes.

Slide 7

Slide 7 text

Computer Science is idealistic

Slide 8

Slide 8 text

"Turing-complete"

Slide 9

Slide 9 text

We first want to prove it is possible

Slide 10

Slide 10 text

async def sleep_sort(numbers): async def sleep_add(number): await asyncio.sleep(number) result.append(number) result = [] await asyncio.wait([ sleep_add(number) for number in numbers ]) return result

Slide 11

Slide 11 text

We can prove that programs are correct

Slide 12

Slide 12 text

def is_two(number): return number == 2

Slide 13

Slide 13 text

>>> import __builtin__ >>> __builtin__.True = False >>> True False >>> True == False True (Thankfully, only works in Python 2!)

Slide 14

Slide 14 text

"Communicating Sequential Processes", C. A. R Hoare

Slide 15

Slide 15 text

contains :: (Ord a) => (Tree a) -> a -> Bool contains Nil _ = False contains (Node t1 v t2) x | x == v = True | x < v = contains t1 x | x > v = contains t2 x

Slide 16

Slide 16 text

A perfect world, of perfect programs

Slide 17

Slide 17 text

“ Benjamin Brewster In theory there is no difference between theory and practice. In practice there is.

Slide 18

Slide 18 text

Software Engineering takes shortcuts

Slide 19

Slide 19 text

When is it safe to take a risk?

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Software is faster and cheaper to change

Slide 22

Slide 22 text

The real world is a nasty place

Slide 23

Slide 23 text

How often does a cosmic ray affect RAM? 36 hours (for 16GB; "SEU at Ground Level", Eugene Normand) How long can an unpowered SSD keep data? 3 weeks - 1 year (Enterprise at 40ºC, Client at 30ºC; Intel/JEDEC) Does quantum tunneling affect CPUs? Continuously!

Slide 24

Slide 24 text

Always design for failure

Slide 25

Slide 25 text

How do we reason about software?

Slide 26

Slide 26 text

Input Process Output

Slide 27

Slide 27 text

async def disable_alarm(): ... async def open_door(): ... await asyncio.wait( [disable_alarm(), open_door()] )

Slide 28

Slide 28 text

Input Rendering Output Validation Reporting Storage Processing Logging Cache

Slide 29

Slide 29 text

Django has 250,000 lines of code

Slide 30

Slide 30 text

An Airbus A380 has 4,000,000 parts

Slide 31

Slide 31 text

A new car has 100,000,000 lines of code

Slide 32

Slide 32 text

How are we supposed to handle this?

Slide 33

Slide 33 text

Abstract, verify and forget

Slide 34

Slide 34 text

Abstract Define a contract - types, behaviour, exceptions Verify Write tests to keep the contract valid Forget Work with the contract, not the fine details

Slide 35

Slide 35 text

You have to learn to forget

Slide 36

Slide 36 text

Engineering is communication

Slide 37

Slide 37 text

“ Grace Hopper A ship in port is safe, but that's not what ships are built for.

Slide 38

Slide 38 text

Build to expect growth

Slide 39

Slide 39 text

Build to expect failure

Slide 40

Slide 40 text

Everyone can build near-perfect software

Slide 41

Slide 41 text

Know when not to!

Slide 42

Slide 42 text

Python lets you do both.

Slide 43

Slide 43 text

Types Start without types, progressively add with mypy Async Make it work synchronously first. Add async later. Speed Write slow, understandable code. Test it. Then improve it.

Slide 44

Slide 44 text

Scientists observe and question

Slide 45

Slide 45 text

Engineers build and invent

Slide 46

Slide 46 text

All software has consequences

Slide 47

Slide 47 text

Be the scientist and the engineer

Slide 48

Slide 48 text

Gracias. Andrew Godwin @andrewgodwin // aeracode.org