require-from-twitter: Help, I don’t get the joke!

A Holberton School student showed me this Gist which is trending right now, and told me he didn’t get the joke.

I looked at it, and I was lucky enough to know the backstory, and get how amazingly brilliant at many levels that joke was! But then explaining the backstory took some time, and while we had a good laugh, I feel more people should know of it and join our joint laughing in appreciation of the author’s witty sense of humor! I also feel that for newcomers to tech culture (like Holberton School’s students), this joke gives an accurate understanding of some key pieces of that culture.

Have a look at it and read through the comments a bit. Still don’t get it? Ok, here’s some backstory you’re probably missing…

First things first: the unpopularity of npm

For every programming language out there, there’s always a way to find people that are excessively committed to it and will defend every aspect of it; but even though you get JavaScript maniacs out there, one thing they all tend to dislike collectively from JavaScript, is npm (the Node Package Manager).

If you don’t know it: in theory, npm allows you to install any application or library written in JavaScript by typing npm install name_of_the_software; it will be directly downloaded from npm. Even better: when you create an application or a library, you can create a package.json file that lists all of the libraries it relies on; then when in that directory, you run npm install, and all of those libraries will download from npm. Magic!
It sounds advanced, but every relevant programming language has a major “package and dependency manager” like that. Ruby has Bundler; Python has pip; for countries where it is relevant, PHP has Composer; etc…

Two major features you expect on those are speed and reliability; and the ire comes from how npm is disappointing in both those respects.
An execution of npm install is so ridiculously slow that some people have gone ahead and developed plugin games that run when npm install is running (like this awesome Space Invaders), and the npm service is known to be down every so often.

To add insult to injury, the JavaScript crowd is usually pretty committed to open-source, and a few years back, Isaac Z. Schlueter, the creator of npm, instead of making it be more maintained by open-source forces, decided to make it a private company and start selling services around npm. While it made sense in an attempt to get more money in order to get a more reliable service, it didn’t go over so well with some of the most heavily committed open-source JavaScript developers.

Getting kik’ed out

Two days ago, a developer by the name of Azer Koçulu published a Medium post titled “I’ve just liberated my modules” explaining that he was terminally mad at npm. He had over 250 libraries on npm, and one of them by name of “kik”. The Kik messaging app didn’t like that Azer was using their trademark, and asked him to give them the ownership of the library, but he wouldn’t. So they contacted npm, and npm transferred the ownership of kik, the library, to Kik, the company.

Azer was so mad at npm, that he decided to remove all of his 250+ libraries from npm in one instant.

Now that could have ended like that. But it didn’t.

The day the internet broke

A funny thing is that most of his packages were tiny, often carrying a single function of 4 to 10 lines. It’s funny because the JavaScript API is notoriously pretty poor, so you do need those kinds of functions on top of raw JavaScript on large projects, but I don’t think many people were aware that there were such short JavaScript libraries (at least, I wasn’t!). It’s also funny, because it tells about some laziness of the developers who didn’t take the time to just copy-paste that short function in their own codebase, in order to avoid one more dependency, and the problems that come with it.

And unfortunately, one of those libraries that got removed that day was “padLeft”, a very simple 11-line function to add some blank spaces in front of numbers in order to display them nicely, and it turns out that particular library was intensely being used. And not only by small projects, but also by very large projects like Babel. All of a sudden, the whole planet could not download libraries like Babel anymore, which broke a lot of installation and deploy scripts everywhere.

It definitely adds to the joke that such large and serious projects would depend on such unseriously small libraries, even though a more likely scenario is that they’re not depending on it directly, but rather using more useful libraries that, themselves, depend on this one. This stresses even more the issues with having unnecessary dependencies.

Now, the joke

So, what is that funny require-from-twitter? Basically, it is a library that will fetch a particular tweet, which is actually a bit of JavaScript code, and will evaluate it to make it available in your JavaScript program. In particular, it fetches a tweet that, if you look at it, contains the code for the infamous padLeft function that created this ordeal.

It is at least double-funny:

  • Not only does it emphasize that if the function fits in the 140 characters of a tweet, it probably should not have been a whole serious library in the first place, which pushes the button of the developers’ laziness for overusing it;
  • But it also makes fun of npm, since Twitter is notoriously pretty fast and with a solid uptime. It hints that even though this is misusing the tool entirely, it’s worth taking those convoluted detours, because Twitter has more of the qualities one would expect from a package/dependency manager than npm does.

And obviously, a major feature of the joke is that this is hilariously over-engineered, considering that just copy-pasting that code into yours would simply have solved the issue in the first place.

There, now you get the joke!

More about it