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.

Learned something new? Want to become a better engineer? 💌

Join 9,400+ people just like you already improving their skills.

Here's how it works 👇

Leave your email and I'll send you an Interactive Modern JavaScript Cheatsheet 📖 right away. After that you'll get a thoughtfully written email every week about React, JavaScript,  and lessons learned in my 20 years of writing code for companies ranging from tiny startups to Fortune5 behemoths.



Man, I love your way of writing these newsletters. Often very relatable and funny perspectives about the mundane struggles of a dev. Lightens up my day. ~ Kostas

PS: You should also follow me on twitter 👉 here.
It's where I go to shoot the shit about programming.