Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Scientist & The Engineer

The Scientist & The Engineer

My keynote from PyCon Colombia 2020.

Andrew Godwin

February 07, 2020
Tweet

More Decks by Andrew Godwin

Other Decks in Programming

Transcript

  1. THE SCIENTIST
    ANDREW GODWIN // @andrewgodwin
    THE ENGINEER
    AND

    View Slide

  2. Hi, I’m
    Andrew Godwin

    View Slide

  3. I call myself an "engineer"

    View Slide

  4. But I studied Computer Science

    View Slide

  5. I knew programming going in.
    But this was different.

    View Slide


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

    View Slide

  7. Computer Science is idealistic

    View Slide

  8. "Turing-complete"

    View Slide

  9. We first want to prove it is possible

    View Slide

  10. 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

    View Slide

  11. We can prove that programs are correct

    View Slide

  12. def is_two(number):
    return number == 2

    View Slide

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

    View Slide

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

    View Slide

  15. 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

    View Slide

  16. A perfect world, of perfect programs

    View Slide


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

    View Slide

  18. Software Engineering takes shortcuts

    View Slide

  19. When is it safe to take a risk?

    View Slide

  20. View Slide

  21. Software is faster and cheaper to change

    View Slide

  22. The real world is a nasty place

    View Slide

  23. 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!

    View Slide

  24. Always design for failure

    View Slide

  25. How do we reason about software?

    View Slide

  26. Input
    Process
    Output

    View Slide

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

    View Slide

  28. Input
    Rendering
    Output
    Validation
    Reporting
    Storage
    Processing
    Logging
    Cache

    View Slide

  29. Django has 250,000 lines of code

    View Slide

  30. An Airbus A380 has 4,000,000 parts

    View Slide

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

    View Slide

  32. How are we supposed to handle this?

    View Slide

  33. Abstract, verify and forget

    View Slide

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

    View Slide

  35. You have to learn to forget

    View Slide

  36. Engineering is communication

    View Slide


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

    View Slide

  38. Build to expect growth

    View Slide

  39. Build to expect failure

    View Slide

  40. Everyone can build near-perfect software

    View Slide

  41. Know when not to!

    View Slide

  42. Python lets you do both.

    View Slide

  43. 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.

    View Slide

  44. Scientists observe and question

    View Slide

  45. Engineers build and invent

    View Slide

  46. All software has consequences

    View Slide

  47. Be the scientist and the engineer

    View Slide

  48. Gracias.
    Andrew Godwin
    @andrewgodwin // aeracode.org

    View Slide