Hey Everybody! Let’s Shit on JS!

3 min read



From my Facebook post:

I hate it when people shit on a language I like. Yeah, JS is a shambles right now. NPM debacle with kik and left-pad, the trillions of lines of spaghetti code written in JS, trying to practice OOP with a prototypal language (there are no classes here, just prototypes which according to people in the know, are bad for classical OOP). It’s fun to shit on JavaScript. It’s fun to call it a terrible language. It is the hip thing to do. It’s the new PHP! It’s the new Java! Whatevs.

Do you know how to write it correctly before you shit on it? No? Then gtfoh with your bullshit. No language is perfect. ABSOLUTELY NONE. Learn how to write it, learn its intricacies. Then talk to me about how terrible it is.

As defensive as I am here, I know JavaScript is sucking hard right now. I know this. There are things about JavaScript that absolutely puzzle me as a new developer, for instance you can’t sort the properties of an Object but you can sort the properties of an Array, which is an object. This makes little sense to newbies. I was informed that Arrays have ordered data and Objects have unordered data, and that sorting an Object would be like sorting an unordered list in HTML.

It made more sense to me after this explanation. So can we really call an Array an Object then? How can an Array be an Object when it has ordered data? Does this have to do with prototypes? I am assuming it does.

But JavaScript isn’t the only language that has this type of garbage. It isn’t as eloquent as Ruby. It doesn’t need to be. They are accomplishing two different things.

Complexity in JavaScript can be a good thing, if people know how to wield that power. Like every language, it has good parts and bad parts.

We could talk about NPM and having a JSON file with 200 dependencies. But what about depending on Ruby gems? Could you break your site with an updated gem that you know nothing about? Absolutely. Can you have 200 dependencies in your Make file? I don’t know. But when I have done a bundle install for whatever project I am working on, there are lots of gems downloaded to the Make file.

No one is Talking About the Real Issue Here

These people using left-pad and kik, these 11 lines of code, a small function that, you know, you should be writing yourself? Why aren’t you? How lazy are you as a developer? If you have to depend on an npm module to add whitespace to the end of a string 1, then you’re a shitty developer.

Micro-dependencies to hide complexity isn’t something we should be doing. Maybe this is a flaw in npm but I really don’t like it and think it’s a bad idea, generally.

Strive to have as few dependencies as possible, where possible. This isn’t a JavaScript thing. Less gems, less npm modules, less swift packages. Just write good code. If you’re a shitty developer, you probably couldn’t care less about any of this. This type of laziness isn’t quarantined to the JavaScript community so let’s stop pretending that is.

  1. I am not totally clear on what left-pad does ↩︎