Posts Javascript is the Right Flavor of Bad
Post
Cancel

Javascript is the Right Flavor of Bad

People are often very hard on Javascript. They make fun of it in “Wat” videos, its community produces a 23 new frameworks every nanosecond, and it’s a common target of criticism among people looking for a dynamically typed language to ridicule.

Yet Javascript is one of my favorite languages to work in, and I think I’ve figured out why: it’s just the right flavor of bad.

Some traditionally bad languages out there (*cough* PHP) are bad deep in their core, buried under layers of pull request makeup and major release plastic surgeries.

It’s a subtle pain. Like stealing socks from your dryer, or unscrewing the lid on your soda bottles while you’re out of the house so that the carbon dioxide escapes and the flavor changes and becomes too sweet and you’re forced to acknowledge that you had planned to drink a bottle entirely filled with corn syrup all along.

It’s a slow burn, a thousand papercuts you can’t put your finger on, and eventually you resign yourself to the pain. You get diabetes from all the soda you’re no longer ashamed to admit to drinking and you’re permanently forced to walk only in smelly circles because you only have one sock left and you’re too afraid to wash it.

But Javascript is different. When it’s bad, it’s a sharp pain, with no attempt to disguise it. It’s like having your cat jump up on your desk and then vomit on it.

It’s clearly, openly, unapologetically rude, and yet the cat just stares innocently, unblinking back at you. As though it just happened to notice your eye contact and is now waiting for you to comment on the weather. Why shouldn’t it throw up on your desk? This looked like a good spot. Why shouldn’t the result of adding two arrays be empty string? It seemed like a good return value.

So you yell at the cat in English, vainly expecting it to understand you in Cat (hint: it does, that’s why it ran away.) Then you clean it up, and the problem is gone. No slow burn. Just something so stupid you can’t believe it happened, with a clear and direct, easily Google-able solution which you quickly apply and then move on with your life.

Javascript is cat puke.

Most of the time it works exactly as you expect, doing cat things and turning strings which contain numbers into 64-bit floats so you can math with them, converting the same numbers into 32-bit integers so you can bitwise operate with them, then converting them back into 64-bit floats so you only have to remember 20 powers of two while working with Javascript numbers.

The good and bad parts of the language are very clear and obvious, which is why it’s possible to learn how to work around them within the lifetime of a mortal. Then you just get the Good Bits of Javascript, and you’re able to enjoy working with it.

"Javascript: the Good Parts"

Javascript, the Good Parts

And then one day you discover Typescript and you elope together and live happily ever after.

This post is licensed under CC BY 4.0 by the author.