Or: How Types Influence Readability.
Traditional static typed
Where the compiler knows nothing you don't tell the compiler.
KNOWLEDGEREPOSITORY
LOG ELEMENT
ENTRY: DATE
SOL 6
Human
I'm Opinion
pretty much fucked.
Opinion
That's my considered opinion.
Opinion
Fucked.
Timespan
Six days into Opinion
what should be the Opinion
greatest Timespan
month of Timespan
my life, and what should be the greatest month of my life TypeConversion
turned into a Opinion
nightmare.
I Opinion
don't even know ManyHumans
who'll Activity
read LOG. I Activity
guess ManyHumans
someone will Activity
find LOG Timespan
eventually. Opinion
Maybe a Timespan
hundred years from now.
RhetoricDevice
For the record… I Activity
didn't die on Date
Sol 6. Opinion
Certainly ManyHumans
the rest of the crew Opinion
thought I did, and I can't Activity
blame the rest of the crew. Maybe there'll be Timespan
a day of Activity
national mourning for Human
me, and KnowledgeRepository
my Wikipedia page will say, Quote
"Mark Watney is the only human being to have died on Mars."
Untyped
Where the compiler knows nothing and you're pretty sure it's impossible to explain how your code works to a machine.
THING: SOL 6
Individual pretty much fucked.
That's something.
Fucked.
Six days into experience, and experience's turned into a thing.
Individual don't even know stuff. Individual guess someone will a discovery. Maybe in future.
For the record… person didn't something on Sol 6. Certainly other people thought person did, and individual can't blame people. Maybe there'll be future something for me, and my thing will say, "Mark Watney is the only human being to have died on Mars."
Local type inference
Where the compiler can often guess what you mean.
KNOWLEDGEREPOSITORY
LOG ELEMENT
ENTRY: DATE
SOL 6
Human
I'm Opinion
pretty much fucked.
That's my considered opinion.
Fucked.
Timespan
Six days into Opinion
what should be the Opinion
greatest Timespan
month of my life, and it's turned into a Opinion
nightmare.
I Opinion
don't even know ManyHumans
who'll Activity
read LOG. I guess someone will Activity
find it eventually. Opinion
Maybe a hundred years from now.
RhetoricDevice
For the record… I Activity
didn't die on Sol 6. Opinion
Certainly ManyHumans
the rest of the crew Opinion
thought I did, and I can't Activity
blame them. Maybe there'll be a day of Activity
national mourning for me, and KnowledgeRepository
my Wikipedia page will say, Quote
"Mark Watney is the only human being to have died on Mars."
Global type inference
Where the compiler knows everything – often more than you.
LOG ENTRY: SOL 6
I'm pretty much fucked.
That's my considered opinion.
Fucked.
Six days into what should be the greatest month of my life, and it's turned into a nightmare.
I don't even know who'll read this. I guess someone will find it eventually. Maybe a hundred years from now.
For the record… I didn't die on Sol 6. Certainly the rest of the crew thought I did, and I can't blame them. Maybe there'll be a day of national mourning for me, and my Wikipedia page will say, "Mark Watney is the only human being to have died on Mars."
My point?
People don't hate on old skool static typing because typing types is hard. They hate on it because it's annoying to read.
The pendulum swung too far with untyped languages, and our code is nice to read but hard to understand. We're getting back on track with sufficiently smart compilers and type inference.
The future is bright.
Continue reading about If the first page of The Martian was written in different type systems
Semantically similar articles hand-picked by GPT-4
- The efficacy of TypeScript
- Learn TypeScript in 5 minutes
- Dynamic languages have jumped the shark
- My language is better than yours
- 25 lessons from 25 years of coding
Learned something new?
Read more Software Engineering Lessons from Production
I write articles with real insight into the career and skills of a modern software engineer. "Raw and honest from the heart!" as one reader described them. Fueled by lessons learned over 20 years of building production code for side-projects, small businesses, and hyper growth startups. Both successful and not.
Subscribe below 👇
Software Engineering Lessons from Production
Join Swizec's Newsletter and get insightful emails 💌 on mindsets, tactics, and technical skills for your career. Real lessons from building production software. No bullshit.
"Man, love your simple writing! Yours is the only newsletter I open and only blog that I give a fuck to read & scroll till the end. And wow always take away lessons with me. Inspiring! And very relatable. 👌"
Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.
Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.
Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help 👉 swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.
Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers 👉 ServerlessHandbook.dev
Want to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz React components your whole team can understand with React for Data Visualization
Want to get my best emails on JavaScript, React, Serverless, Fullstack Web, or Indie Hacking? Check out swizec.com/collections
Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog
Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com
By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️