Top Banner
The Epistemology of Software Engineering Nathan Marz @nathanmarz 1
150

The Epistemology of Software Engineering

Jan 15, 2015

Download

Technology

nathanmarz

My keynote at GOTO Berlin 2013
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 1: The Epistemology of Software Engineering

The Epistemology of Software Engineering

Nathan Marz@nathanmarz 1

Page 2: The Epistemology of Software Engineering

My personal philosophies on software development

Page 3: The Epistemology of Software Engineering
Page 4: The Epistemology of Software Engineering

Agenda1. Limits of human knowledge

2. Effect of the limits of knowledge on software development

3. Embracing those limits enables you to build better software

Page 5: The Epistemology of Software Engineering

How do I know my software is correct?

Page 6: The Epistemology of Software Engineering

How do I know a proposition is true?

Page 7: The Epistemology of Software Engineering

Epistemology

Page 8: The Epistemology of Software Engineering

How do I know my software is correct?

PREVIEW

Page 9: The Epistemology of Software Engineering

You don’t

Page 10: The Epistemology of Software Engineering

Your code is wrong

Page 11: The Epistemology of Software Engineering

PREVIEW

How do I know a proposition is true?

Page 12: The Epistemology of Software Engineering

You don’t

Page 13: The Epistemology of Software Engineering

True knowledge is unattainable

Page 14: The Epistemology of Software Engineering
Page 15: The Epistemology of Software Engineering
Page 16: The Epistemology of Software Engineering

But wait... philosophy?

Page 17: The Epistemology of Software Engineering

Fallacies

StrawmanAppeal to authority

Circular reasoningAppeal to emotion

False dilemmaArgument to moderation

Moral highgroundAd hominem attackShotgun argumentationCorrelation vs causationEquivocationBurden of proof

Page 18: The Epistemology of Software Engineering
Page 19: The Epistemology of Software Engineering

Your code is wrong

Page 20: The Epistemology of Software Engineering

Your code is literally wrong

Page 21: The Epistemology of Software Engineering

Your code is wrong

Page 22: The Epistemology of Software Engineering
Page 23: The Epistemology of Software Engineering

Why do you believe your code is correct?

Page 24: The Epistemology of Software Engineering

Your code

Dependency 1

Dependency 2

Dependency 3

Page 25: The Epistemology of Software Engineering

Dependency 1

Dependency 4

Dependency 5

Page 26: The Epistemology of Software Engineering

Dependency 4

Dependency 6

Dependency 9

Dependency 7

Dependency 8

Page 27: The Epistemology of Software Engineering

Dependency 3,000,000

Hardware

Page 28: The Epistemology of Software Engineering

Electronics

Page 29: The Epistemology of Software Engineering

Chemistry

Page 30: The Epistemology of Software Engineering

Atomic physics

Page 31: The Epistemology of Software Engineering

Quantum mechanics

Page 32: The Epistemology of Software Engineering

I think I can safely say that nobody understands

quantum mechanics.

Richard Feynman

Page 33: The Epistemology of Software Engineering

Your code is wrong

Page 34: The Epistemology of Software Engineering

Your code

...

Page 35: The Epistemology of Software Engineering

Infinite regress

Page 36: The Epistemology of Software Engineering

Epistemological “solutions”1. Infinitism

2. Foundationalism

3. Coherentism

Page 37: The Epistemology of Software Engineering

Coherentism

Page 38: The Epistemology of Software Engineering

Foundationalism

Axioms

Page 39: The Epistemology of Software Engineering

René Descartes

Page 40: The Epistemology of Software Engineering

Cogito ergo sum

Page 41: The Epistemology of Software Engineering

I think, therefore I am

Page 42: The Epistemology of Software Engineering

Codito ergo sum

Page 43: The Epistemology of Software Engineering

I code, therefore I am

Page 44: The Epistemology of Software Engineering

Cartesian foundationalism1. Limited axioms

2. Knowledge through deduction

Page 45: The Epistemology of Software Engineering

Cartesian programming1. Axioms = rules of programming language

2. Programs = deductions from those axioms

Page 46: The Epistemology of Software Engineering
Page 47: The Epistemology of Software Engineering
Page 48: The Epistemology of Software Engineering
Page 49: The Epistemology of Software Engineering

-> OutOfMemoryException

Page 50: The Epistemology of Software Engineering

-> Hallo welt!

Page 51: The Epistemology of Software Engineering

All the software you’ve used has had bugs in it

Page 52: The Epistemology of Software Engineering

Including the software you’ve written

Page 53: The Epistemology of Software Engineering
Page 54: The Epistemology of Software Engineering
Page 55: The Epistemology of Software Engineering
Page 56: The Epistemology of Software Engineering
Page 57: The Epistemology of Software Engineering

Induction

Page 58: The Epistemology of Software Engineering

f(0) and (f(n) → f(n+1)) ⇒ ∀n≥0, f(n)

Page 59: The Epistemology of Software Engineering

Induction

Page 60: The Epistemology of Software Engineering
Page 61: The Epistemology of Software Engineering
Page 62: The Epistemology of Software Engineering

<sidenote>

Page 63: The Epistemology of Software Engineering

David Hume

Page 64: The Epistemology of Software Engineering

“Why is inductive reasoning valid?”

Page 65: The Epistemology of Software Engineering

</sidenote>

Page 66: The Epistemology of Software Engineering
Page 67: The Epistemology of Software Engineering

Skepticism

Page 68: The Epistemology of Software Engineering
Page 69: The Epistemology of Software Engineering

perfect code

Page 70: The Epistemology of Software Engineering

value to users

Page 71: The Epistemology of Software Engineering

“My software is correct”

Page 72: The Epistemology of Software Engineering

“My software is sometimes correct”

Page 73: The Epistemology of Software Engineering

How do you minimize imperfection?

Page 74: The Epistemology of Software Engineering

Storm’s “reportError” method

Page 75: The Epistemology of Software Engineering

(Storm is a realtime computation system, like Hadoop but for realtime)

Page 76: The Epistemology of Software Engineering

Storm architecture

Page 77: The Epistemology of Software Engineering

Storm architecture

Master node (similar to Hadoop JobTracker)

Page 78: The Epistemology of Software Engineering

Storm architecture

Used for cluster coordination

Page 79: The Epistemology of Software Engineering

Storm architecture

Run worker processes

Page 80: The Epistemology of Software Engineering

Storm’s “reportError” method

Page 81: The Epistemology of Software Engineering

Used to show errors in the Storm UI

Page 82: The Epistemology of Software Engineering

Error info is stored in Zookeeper

Page 83: The Epistemology of Software Engineering

What happens when a user deploys code like this?

Page 84: The Epistemology of Software Engineering

Denial-of-service on Zookeeper and cluster goes down

Page 85: The Epistemology of Software Engineering

Robust!

Designed input space Actual input space

Failures!Bad performance!Security holes!

Irrelevant!

Page 86: The Epistemology of Software Engineering

Implement self-throttling to avoid overloading Zookeeper

Page 87: The Epistemology of Software Engineering

Robust!

Designed input space Actual input space

Page 88: The Epistemology of Software Engineering

Robust!

Designed input space Actual input space

Page 89: The Epistemology of Software Engineering

Epistemology

Page 90: The Epistemology of Software Engineering

TrthTruh

Trut

TuthTru

Page 91: The Epistemology of Software Engineering

Foundation of modern science

Page 92: The Epistemology of Software Engineering

1. When viewed in an inertial reference frame, an object either is at rest or moves at a constant

velocity, unless acted upon by an external force.

2. The acceleration of a body is directly proportional to, and in the same direction as, the net force acting on the body, and inversely proportional to its mass. Thus, F = ma, where F is the net force acting on the object, m is the mass of the object and a is the acceleration of the object.

3. When one body exerts a force on a second body, the second body simultaneously exerts a force equal in

magnitude and opposite in direction to that of the first body.

Newton’s laws of motion

Page 93: The Epistemology of Software Engineering

Cambridge, we have a problem...

Orbit of Mercury problem

Page 94: The Epistemology of Software Engineering

Einstein’s theory of relativity

Sorry, Newton, you’vebeen PWNED:

Page 95: The Epistemology of Software Engineering

limitn → ∞

approximation (truth)n = truth

Page 96: The Epistemology of Software Engineering

Science algorithm1. Make observations

2. Find theories consistent with those observations

3. Falsify theories by making more observations

Page 97: The Epistemology of Software Engineering

Foundationalism

Coherentism+

Page 98: The Epistemology of Software Engineering

Empiricism

Page 99: The Epistemology of Software Engineering

John Locke

Page 100: The Epistemology of Software Engineering
Page 101: The Epistemology of Software Engineering
Page 102: The Epistemology of Software Engineering
Page 103: The Epistemology of Software Engineering
Page 104: The Epistemology of Software Engineering
Page 105: The Epistemology of Software Engineering
Page 106: The Epistemology of Software Engineering

Occam’s Razor

Page 107: The Epistemology of Software Engineering

Software

Use cases

Page 108: The Epistemology of Software Engineering

Software gets messy

Page 109: The Epistemology of Software Engineering

Refactoring

Page 110: The Epistemology of Software Engineering

Robust!

Designed input space Actual input space

Page 111: The Epistemology of Software Engineering

Robust!

Designed input space Actual input space

Page 112: The Epistemology of Software Engineering
Page 113: The Epistemology of Software Engineering

TESTING

Page 114: The Epistemology of Software Engineering
Page 115: The Epistemology of Software Engineering
Page 116: The Epistemology of Software Engineering

Unit testing

Load testing

Stress testing

Fuzz testing

Page 117: The Epistemology of Software Engineering

TDD?

Page 118: The Epistemology of Software Engineering

Review1. Cannot perfectly reason about software• Infinite regress problem• Deduction is fundamentally flawed• Evidence shows programmers are not good at deductive reasoning

2. Best you can do is minimize wrongness• Truth can only be approximate• Observe/theorize/falsify cycle minimizes wrongness over time• Testing = empiricism applied to software development• Make programs less wrong by testing more

Page 119: The Epistemology of Software Engineering

Does any of this matter?

Page 120: The Epistemology of Software Engineering

YES

Page 121: The Epistemology of Software Engineering

Embrace “your code is wrong”to design better software

Page 122: The Epistemology of Software Engineering
Page 123: The Epistemology of Software Engineering
Page 124: The Epistemology of Software Engineering

RedundancyFault-tolerance > Perfection

Page 125: The Epistemology of Software Engineering

An example

Page 126: The Epistemology of Software Engineering

Learning from Hadoop

Jobtracker

Job

Job

Job

Page 127: The Epistemology of Software Engineering

Learning from Hadoop

Jobtracker

Job

Job

Job

Page 128: The Epistemology of Software Engineering

Learning from Hadoop

Jobtracker

Job

Job

Job

Page 129: The Epistemology of Software Engineering

Your code is wrong

Page 130: The Epistemology of Software Engineering

So your processes will crash

Page 131: The Epistemology of Software Engineering

Storm’s daemons are process fault-tolerant

Page 132: The Epistemology of Software Engineering

Storm

Nimbus

Topology

Topology

Topology

Page 133: The Epistemology of Software Engineering

Storm

Nimbus

Topology

Topology

Topology

Page 134: The Epistemology of Software Engineering

Storm

Nimbus

Topology

Topology

Topology

Page 135: The Epistemology of Software Engineering

Storm

Nimbus

Topology

Topology

Topology

Page 136: The Epistemology of Software Engineering

Storm

Nimbus

Topology

Topology

Topology

Page 137: The Epistemology of Software Engineering

Robust!

Designed input space Actual input space

Page 138: The Epistemology of Software Engineering

Robust!

Designed input space Actual input space

Page 139: The Epistemology of Software Engineering

Reasoning is fundamentally hard

Page 140: The Epistemology of Software Engineering

So program in ways that require less of it

Page 141: The Epistemology of Software Engineering
Page 142: The Epistemology of Software Engineering
Page 143: The Epistemology of Software Engineering

Pure function

Page 144: The Epistemology of Software Engineering

Mutability is hard to reason about

Page 145: The Epistemology of Software Engineering

Minimize state mutation

Page 146: The Epistemology of Software Engineering

Functional programming

Page 147: The Epistemology of Software Engineering

Clojure

Page 148: The Epistemology of Software Engineering

skepticism(skepticism)

Page 149: The Epistemology of Software Engineering

perfect software

??

?

??

??

??

???

??

??

?

?? ????

??

?

?

? ?

Page 150: The Epistemology of Software Engineering

Thank you