If Socrates met Linus Torvalds, what would they talk about? How much math should be bundled into a good programming language? Can compiler resolve an argument and prove, that someone is right? Trough semantics of code, that we write every day, when looking carefully, one can see foundations of logic and science, that has been build more than 2000 years ago. Why does it matter, and how can we leverage this enormous power to make our code safe and sound in languages with advanced type systems, like Typescript and Scala.
9. Pythagoras (570 – 495 BC)
• Founder of Pythagoreanism;
• The first man to call himself a
philosopher ("lover of wisdom”);
• One of the earliest vegetarians.
10.
11. Socrates (570 – 495 BC)
• Famous by Plato’s dialogues;
• One of the founders of Western
philosophy;
• Socratic method
12. - Teacher:What is happening to our global climate?
- Stan: It’s getting warmer.
- Teacher: How do you know it’s getting warmer? What evidence do
you have to support your answer?
- Stan: We have all of these record heat days.
- Teacher: How do you know this is true?
- Stan: Scientists are saying that
- Teacher: How would they know?
- Stan:They have special equipment.
Source: Intel Tech Program, Designing Effective Projects
13. Socratic method
• False ignorance
• Goading (provoking, often by questions)
• Exposing fundamental premises
• Showing contradictions
14. Aristotle (470 – 399 BC)
• Along with Plato, he is considered
the "Father of Western Philosophy”;
• Defined syllogisms and introduced
Aristotelian logic;
15.
16. Syllogisms and term logic
- No reptiles have fur;
- All snakes are reptiles;
- Therefore, no snakes have fur.
- No R have F;
- All S are R;
- Therefore, no S have F.
17. P: No one is free who has not obtained the
empire of himself.
M: I started the site when I was 19. I
didn't know much about business back
then.
S: The unexamined life is not worth living
L: Talk is cheap. Show me the code.
A: Let’s use symbols! For instance:
Every C is B
Every C is A
So, some A is B
H: Program is a proof
Pythagoras M. Zuckerberg
L.Torwalds
H. CurryAristotle
Socrates
18. Hey, Haskell, tell me more.
What do you mean by a “program is a proof” ??? 🤔
A moment ago
Haskell is typing…
19. That language is an instrument of human
reason, and not merely a medium for the
expression of thought, is a truth
generally admitted.
George Boole (1815 - 1864)
It is unworthy of excellent men to lose
hours like slaves in the labour of
calculation which could safely be
relegated to anyone else if machines were
used.
Gottfried Wilhelm Leibniz (1646 - 1716)
Yo! Check out those dudes 👇
A moment ago
22. Impressive! So people don’t make those stupid logical
mistakes anymore? 😈
20 seconds ago
%They do, but we’ve learned a lot…
10 seconds ago
23. Argument validity
Impossible for the premises to be true and
the conclusion false at the same time
✤ Animals that fly can live in trees
✤ Cats can fly
✤ Therefore cats can live in trees
24. Argument soundness
Not only valid, but the premises
are actually true
✤ Animals that fly can live in trees
✤ Cats can not fly
✤ Therefore cats can not live in trees
25. After this, therefore because of this
(Post Hoc, Ergo Propter Hoc)
Right when I sneezed, the power went off.
I must’ve caused the outage.
26. Genetic Fallacy
✤ Ha! I’m not reading that book.
✤ It was published inTennessee, and we
know allTennessee folk are hillbillies and
rednecks!
28. Argument from force
(Argumentum ad Baculum)
✤ You say there’s no way you can finish the
project next week?
✤ Bullshit! Find a way! Make it happen! Just
do it!
✤ This is a million dollar contract and we
need it done byTuesday.
30. Yes, talk is cheap,
show me the code!
But what about
programming?
31. Curry-Howard
isomorphism
In order to prove any mathematical
theorem, all we have to do is construct a
certain type which reflects the nature of
that theorem, then find a value that has that
type.
32. Math Computer science
Proofs
Formulas
Programs
Types
A implies B
A and B
A or B
Function from A => B
Tuple of A and B
Union of A and B
falsity
truth
empty type
singleton type
Axiom
Soundness Theorem
Completeness Theorem
Incompleteness Theorem
System Primitive
Compiler
Debugger
Infinite loop
33. Math Computer science
Double negation First class callbacks
Friedman’s translation
Dynamic Exceptions
Cohen’s Forcing Global Variables
Dialectica Translation
Scoped goto’s (e.g. Python’s
yield)
34. So, we are using math to describe the world.What are
you using your software stuff for?
3 minutes ago
We kind of create a virtual world with our own
rules…
20 seconds ago
Wow, how far you have gone!
A moment ago
35. I bet your tools guarantee that errors like in those
arguments can never even happen in this new world.
A minute ago
I wish…
A moment ago
36. Paradigm Description
Imperative, Structured,
Procedural
Programs as statements that directly change
computed state (datafields). Also with procedure calls.
Functional
Treats computation as the evaluation of mathematical
functions avoiding state and mutable data
Event-driven
Control flow is determined mainly by events, such
as mouse clicks or interrupts including timer
Object-oriented
Treats datafields as objects manipulated through
predefined methods only
Declarative Defines program logic, but not detailed control flow
Automata-based
programming
Treats programs as a model of a finite state machine or
any other formal automata
PROGRAMMING PARADIGMS
Source:Wikipedia:Comparisonofprogrammingparadigms
42. Uh…That hurts my ancient geek brain!
5 seconds ago
Why would people do this?
43. “When it gets hard, we build
more escape hatches and tell
users to be careful.”
Amal Ahmed,All The Languages Together.
Presented at Strange Loop 2018
44. “I made up the term object-
oriented, and I can tell you I
did not have C++ in mind.”
Alan Kay, has designed a few programming languages
48. All good counsel begins in the same way; a man should know
what he is advising about, or his counsel will all come to
nought. But people imagine that they know about the nature
of things, when they don't know about them, and, not having
come to an understanding at first because they think that
they know, they end, as might be expected, in
contradicting one another and themselves.
Just now
I would hang this into every meeting room on this
planet!
A moment ago
63. // # 4.1 First class function
List(1, 2, 3).map(x => x * 2)
// List(2, 4, 6)
64. // # 4.2 Higher order functions
def plus(a: Int, b: Int): Int = a + b
def plus_(a: Int)(b: Int): Int = a + b
def plus5: Int => Int = plus_(5)
plus5(2) // = 7
74. // Type inference
// Local variable
const x = 2 * 2 // number
// Best common type
const y = [0, 1, null]; // (number | null)[]
// Context based
window.onmousedown = mouseEvent => {
// mouseEvent: MouseEvent
console.log(mouseEvent.button);
};
75. • Math is the most precise and unambiguously language that describes
the world.
• It’s the most advanced and rich language as well.
• “Invest” in math friendly languages.
• For Math = Correctness.
• And that gives you confidence.
77. Inclusive and language-agnostic meetup
group for those who cares about
TypeSafety
~ welcomes new members and potential speakers ~
http://slack.typesafeutrecht.net
http://meetup.typesafeutrecht.net