Dipperstein All articles
Deep Dives

The Kettle, the Ladle, and the Compiler: A Soaking-Hot Tour of Type Strictness

Dipperstein
The Kettle, the Ladle, and the Compiler: A Soaking-Hot Tour of Type Strictness

It Started With a Burnt Finger

I was making jam on a Saturday — the kind of domestic project that exists mostly as an excuse to buy a candy thermometer — and I did the thing every American kitchen veteran does: I dipped a finger in to check the temperature. The finger disagreed with the kettle. The kettle won.

Standing there with a running tap, I realized I'd just run an informal type check. The kettle had a type — boiling water, 212°F, do not touch — and I had ignored the annotation. JavaScript would've shrugged and handed me undefined. Rust would've refused to compile my hand.

So I did what any reasonable engineer does with a half-formed metaphor: I took it way too far. I built three "dip tests" — one for each tier of type strictness — and ran them against real code I had lying around. Here's the field report.

Dip Test #1: The Toe (JavaScript, or "Trust Me, It's Fine")

Dipping a toe into a hot tub is the loosest possible contract. Nobody hands you a spec sheet. You extend a limb, gather feedback at runtime, and adjust. If the water is 40 degrees too hot, you find out with your foot.

That's JavaScript. The language will happily let you do this:

function brew(temperature) {
  return temperature + " degrees";  // wait, is this a number or a string?
}

brew(212);        // "212 degrees"
brew("212");      // "212 degrees" — sure, why not
brew(undefined);  // "undefined degrees" — the toe is now scalded

JavaScript never stops you at the door. Everything is checked at the moment of contact, which in programming terms means in production, on a Saturday, while your pager buzzes. I pulled up an old side project of mine — a recipe scaler, fittingly — and found four places where a number could arrive as a string and quietly concatenate instead of add. All four had shipped. All four had been discovered by users, i.e., by the toe.

There's a real argument for this looseness. For a 200-line script, dynamic typing is a ladle: grab it, dip it, move on. The ceremony of types would cost more than it saves. The trouble starts when the codebase grows legs.

Dip Test #2: The Candy Thermometer (TypeScript, or "Check Before You Commit")

A candy thermometer changes the game. You don't touch the liquid — you insert an instrument designed to be in there, and it reports back with annotations: thread, soft ball, hard crack. The feedback happens before your skin does.

TypeScript is that thermometer. The runtime is still JavaScript — the water is still water — but now you've clipped a checking device onto the side of the pot:

function brew(temperature: number): string {
  return temperature + " degrees";
}

brew(212);        // ✅
brew("212");      // ❌ Argument of type 'string' is not
                  //    assignable to parameter of type 'number'

The error above fires in my editor before I save the file. That's the whole pitch: move the discovery of the mistake from scalded toe to thermometer reading. Same water, same kettle, radically different pain profile.

I migrated that recipe scaler to TypeScript in an afternoon. TypeScript found eleven issues. Ten were trivial — a missing null check here, an any that had been hiding a string there. The eleventh was a genuine bug where a fraction could be 0 and divide the whole recipe into NaN. That one alone paid for the migration.

But strictness has a tax, and the tax shows up at the edges. Every API response, every JSON file, every process.env value arrives as unknown — the type system's way of saying "this water could be anything." You end up writing validators, little border checkpoints where untyped data gets inspected before it enters the country. It's worth it. It's also work, and pretending otherwise is how you get codebases that are "TypeScript" the way a hotel is "smoke-free."

Dip Test #3: The Pressure Cooker Seal (Rust, or "You May Not Open This")

Then there's the strictest regime I tried: Rust. If JavaScript is a toe and TypeScript is a thermometer, Rust is a pressure cooker with a locking lid and an interlock that physically prevents you from opening it while pressurized. You cannot dip anything. You must declare, up front, what's going in and what's coming out, and the compiler treats your good intentions as legally binding.

The famous example is null safety. In Rust, absence isn't a surprise lurking in the water — it's a type:

fn brew(temperature: Option<f64>) -> String {
    match temperature {
        Some(t) => format!("{} degrees", t),
        None => String::from("kettle unplugged"),
    }
}

The compiler will not let you forget the None case. Ever. The first week I fought it constantly — borrow checker this, lifetime that — and I won't pretend the learning curve is a curve so much as a wall with a rope ladder. But here's what surprised me: after the wall, I stopped thinking about entire categories of bug. Nulls. Data races. Use-after-free. They're not bugs I catch; they're bugs that can't be written.

For a solo developer, that matters more than it sounds. I don't have a reviewer catching my 2 a.m. mistakes. The compiler is the reviewer, and Rust's reviewer is relentless.

So When Does Strictness Actually Pay Off?

After all three dips, here's my verdict, calibrated for the one-person shop:

The jam, for the record, set perfectly. The thermometer said 220°F, I trusted the annotation, and nobody got burned. Which is, when you think about it, the entire sales pitch for static typing — you just usually have to learn it with a finger instead of a compiler.

All Articles

Related Articles

My Well Pump Is the Worst Database I've Ever Administered

My Well Pump Is the Worst Database I've Ever Administered

The Big Dipper Doesn't Move, But My Tripod Sure Did: A Star Tracker Built Out of Junk Drawer Physics

The Big Dipper Doesn't Move, But My Tripod Sure Did: A Star Tracker Built Out of Junk Drawer Physics

Burying a Library With Dignity: Confessions of an Open-Source Undertaker

Burying a Library With Dignity: Confessions of an Open-Source Undertaker