DEV Community

Cover image for How My Coffee Maker Taught Me to Love Types
Mario Vega
Mario Vega

Posted on

How My Coffee Maker Taught Me to Love Types


That one word had hung around the edges of my consciousness for months. VS Code would suggest the .ts extension for every new file I created, and every time my answer would be, "Not today." Looking up the implementations of JavaScript functions would bring me to TypeScript type definition files, which always looked a tad too intimidating to parse. I'd read quotes about the growing inevitability of typed JavaScript and think that that inevitability didn't apply to me. When had I ever run into a problem that typing would solve?

Little did I know that the evangelist that would convert me to the typed way would be my own coffee maker.

Like many work-inclined people I know, coffee fuels a large part of my working day. And like many developers I know, I follow my creative inspirations wherever they might take me -- often into the small hours of the night. At the end of my working hours, I typically set a pot of coffee on autobrew for the following morning so I can start my next day without missing a beat.

One day a couple weeks ago, I woke up to a calamity: coffee grounds everywhere. Coffee grounds in my coffee, coffee grounds on the counter, coffee grounds trailing down my cabinet doors and pooling on the kitchen floor below.

As it turns out, in my early-morning code-addled stupor, I had forgotten to put the filter back into my coffee after cleaning it. It was in that moment of cleaning coffee grounds that I realized why I had to start typing my JavaScript immediately.

Effectively, I realized that my coffee maker was like vanilla JavaScript. It was happy to let my delirious, inattentive self set my coffee up however I wanted. There were no checks to make sure that I had put in a new filter, no checks that I had put in new coffee grounds, no checks that I had put in water, no checks whatsoever to ensure that I would actually have coffee in the morning and not a waterfall of wasted grounds. Any problems that resulted from my coffee setup would have to be handled when it was time to brew, not while setting up and actually had the time and (some of) the attention span to fix things.

If my coffee machine had been strictly typed? Sure, maybe I would have been annoyed that my machine was bleeping at me to fix my improper setup when the only thing I wanted to do was go to sleep. But I would have fixed things all the same, and my diligence would have been rewarded with morning coffee.

There are few things more important to me than coffee, and properly-working code is one of them. So, while the jury's still out on when we'll see strong typing make its way into home appliances, I decided right then and there that I would start my journey into TypeScript.

Top comments (5)

maciekgrzybek profile image
Maciek Grzybek

Is that… CoffeeScript?

adam_cyclones profile image
Adam Crockett πŸŒ€ • Edited

TypeCoffeeScript now that would be interesting.

Looks like that's a thing, funded project aswell.

mariowhowrites profile image
Mario Vega

I did, in fact, originally include a CoffeeScript pun in this post. It felt forced, so I took it out and left the setup for a particularly astute commenter ;)

fischgeek profile image

I've seen this post float by my feed a few times. Finally I decided to read it. I must say, you have a talent for story telling. I was riveted. Fantastic story and really well done. Thanks for the good read!

steveblue profile image
Stephen Belovarich • Edited

What a great story! You combined my two favorite things TypeScript and Coffee β˜•οΈ

Bringing types to JavaScript is possibly the best part of TypeScript. I also love how TypeScript allows you to code with future spec as well. The TypeScript compiler is pretty incredible too.