Warm-up Game
Play game and infer the rule of the
game.
What programming concept is this
game referring to?
http://tinyurl.com/hd-game
First Principles
Thinking
Unleash your engineering creativity
Hung Doan
Software Engineer @ Coda.io
Lead CS Instructor @ Steam For Vietnam
High School
Gà chọi…
Luyện thi…
Practicing with more problem set wasn’t effective…
Time to change strategy
● It was summer of Grade 11
● Back to the basic: 1 month
○ Fundamental algorithms
○ Data structures
○ Graph theories
Time to change strategy
● It was summer of Grade 11
● Back to the basic: 1 month
○ Fundamental algorithms
○ Data structures
○ Graph theories
● Redo previous problem sets: 1 month
○ Break down the problem
○ Identify which tool is suitable and when
○ Solidify my coding skills
It’s the learning
that stick
First Principles Thinking
1. What is First Principles
Thinking?
2. How to apply it in Software
Development?
3. What risks should I watch out
for?
First Principles
Thinking
Break problems
down to their
fundamental
truths
Tìm về gốc rễ của vấn đề
First Principles Thinking
It’s a Problem
Solving
Framework
How do we solve problem?
How do we solve problem?
How do we solve problem?
Solution for a generic quadratic equation
How do we solve problem?
Problem Solving
At school, we learn to memorize formulas and question templates
● Math
● Physics
● Chemistry
● English
● Literature
● … and Software Engineering
Problem Solving
At school, we learn to memorize formulas and question templates
● Math
● Physics
● Chemistry
● English
● Literature
● … and Software Engineering
Problem Solving
At school, we learn to memorize formulas and question templates
● Math
● Physics
● Chemistry
● English
● Literature
● … and Software Engineering
Analogical Reasoning,
Pattern Matching
Analogical Reasoning
● Fast to create a solution
● Easy to replicate
But not all
problems in life
are solved…
Beal’s Conjecture: $1,000,000
Chef vs Cook
Creating a new dish
VS. Following the recipes
But how to be a
chef?
Knows the
fundamentals
● Ingredients
● Nutrition
● Taste
● Combinations
● Experiments
=> Come up with new dishes.
First Principles Thinking
First Principles Thinking
Elon Musk’s
Key to
Innovation
SpaceX
● Cheaper spacecrafts
● Recoverable, reusable
spacecrafts
SpaceX
$65 Millions
SpaceX
Hold up…
$65 Millions
SpaceX
= Aluminum Alloy
Titanium
Copper
Carbon Fiber
Materials
SpaceX
How to develop First
Principles Thinking
habits?
Techniques
to arrive at
first
principles
thinking
Interested in understanding
the problem
Five whys (5 câu hỏi tại sao)
Cartesian method of doubts
(phương pháp nghi vấn Descartes)
Socratic questioning
(phương pháp truy vấn biện chứng)
Why?
Is that
correct?
Are you
sure?
Why?
Why?
Why?
Why?
What __?
How __?
Why __?
5 whys
Move past symptoms by asking “why” until reaching true root cause of the issue
“If I had an hour
to solve a
problem I'd
spend 55
minutes
thinking about
the problem and
five minutes
thinking about
solutions”
Albert Einstein
I don’t know
how to code
I can write
code but
uncertain if it
works
What am I
not clear
about?
I understand
X clearly
Thinking out of the box?
?
?
?
?
Thinking out of the box?
Thinking in a bigger box!
Application in
Software Engineering
Warm-up Game
What are the rules of the game?
What programming concept does
this game refer to?
Warm-up Game
It’s variable scope!
● Local scope (house)
● Global scope (community park)
“Know” the
fundamentals
● Functions, Variables,
Classes
● Memory
● Thread
● Data structures (array,
map, …)
● Coding skills
Effective debugging
● Mismatch between
human understanding <> computer
● Treat it as an opportunity to
learn about the codebase & system
Example: Timezone bug
Example: Timezone bug
Offset = X
Example: Timezone bug
Offset = X Offset = X”
Example: Timezone bug
Collect new
building blocks
● API Design
● Distributed System
● Micro Services
● Product Thinking
● Business Domain
Knowledge
● Communication Skills
● etc.
System Design
By understanding the building blocks of a
system, you can challenge existing systems
and come up with fundamentally different
solutions
Case study:
Sorbet-rails
Generating static signatures
for dynamic Ruby methods
(methods generated at
runtime)
Case study:
Sorbet-rails
Generating static signatures
for dynamic Ruby methods
(methods generated at
runtime)
The popular way of solving this problem, adopt by other
libraries like Shopify’s tapioca, and Ruby’s own RBS system
Case study:
Sorbet-rails
Leveraged my knowledge of:
● Sorbet
● Rails
● Codegen (learned @ FB)
To come up with a different
solution for type-checking
dynamic methods
What are dynamic methods?
How are they created?
When are they created?
When do they change?
What should their signature be?
Case study:
Sorbet-rails
What are dynamic methods?
How are they created?
When are they created?
When do they change?
What should their signature be?
Generate signature once
Use for every type-checks
Leveraged my knowledge of:
● Sorbet
● Rails
● Codegen (learned @ FB)
To come up with a different
solution for type-checking
dynamic methods
Case study:
React
Rethinking front-end
development
● Build reusable
Components
● Rerender when data
change
Case study:
React
Rethinking front-end
development in principles:
● Increase cohesion,
reduce coupling
● Composition over
inheritance
● Simplify state change
handling by re-rendering
instead of mutating
Pete Hunt: React: Rethinking best practices
Engineering
Career Growth
● Entry Engineer
● Junior Engineer
● Senior Engineer
● Staff+ Engineer
Increasingly bigger
problem scope!
Engineering
Career Growth
● Entry Engineer
● Junior Engineer
● Senior Engineer
● Staff+ Engineer
Increasingly bigger
problem scope!
PSHE: Increasingly
ambiguous problems
Problem
(Given blank space, find problems
worth solving)
Solution
(Given Problem, solve it)
How
(Given Solution, how to implement)
Execute
(Given plan, write code)
Finding “Problems”
● Understand the system
● Observe, notice problems
● Decide the problem to solve
● Propose new solutions for the problem
=> Staff+ level
Do I need to know
how transistors
work to code?
Risks
● Spend too much time learning vs. making impact
● Make the wrong propositions & conclusions
● Focus on unimportant problems
Dig N+1 Layer
Deeper
● Stay Curious.
● Learn about the layer
underneath.
● Timebox exploration.
● Use analogical
reasoning for familiar
problems.
Making wrong conclusion?
Validate ideas
with data
● Always question your
assumptions
● Use data to prove or disprove
them
Find one impactful problem is
more important than solving
many unimportant problems.
Summary
Break down problems to
fundamental parts to build
solution.
Build solid fundamental skills.
Stay curious. Be observant. Ask many questions, like
“What do I not know?” “What
am I not sure about?”
Q & A
“I only teach stress
and the end of stress”
Cartesian method of doubts
● https://en.wikipedia.org/wiki/Cartesian_doubt
● Doubting every assumptions, we realize we can go deeper
Socratic Questioning
● Know what you don't know
● https://en.wikipedia.org/wiki/Socratic_questioning
the level of thinking that occurs is influenced by the level of questions asked
iPhone
● Multi-touch screen
● Sensors
● Mobile Web
Browser
Before iPhone
Before iPhone
Think
different
iPhone
User
Calling
Music
Web
iPhone
User
Calling
Music
Web
iPhone
iPhone 1 -> N
Source: bankmycell.com
Other phones
Source: Arstechnica
Case study:
React
● Develop reusable
components
● Declarative UI rendering
code
● Maintain a virtual
Document Object Model
(DOM)
Case study:
React
● Maintain a virtual
Document Object Model
(DOM)
● Declarative rendering
code
“What if developer focuses on
rendering components based
on state as opposed to
modifying DOM?”
Analogical
Reasoning
● Fast to arrive at solution
● Easy to replicate
Analogical Reasoning
● Fast to create a solution
● Easy to replicate
Going from 0 => 1?
● It's much harder
● But not all problems in the world are already solved
● New problems
First principles thinking
● For breakthrough innovation
● Breaking a problem space down to its building blocks
● Then building up a different solution
First principles thinking
Case study:
Sorbet-rails
Leveraged my knowledge of:
● Sorbet
● Rails
● Codegen (learned @ FB)
To come up with a different
solution for type-checking
dynamic methods
The popular way of solving this problem, adopt by other
libraries like Shopify’s tapioca, and Ruby’s own RBS system
Dig N+1 Layer
Deeper
● Stay Curious
● Learn about the layer
underneath

Grokking Techtalk #45: First Principles Thinking