JavaScript is bad.

JS is a most popular technology, and second most wanted technology on the market, according to Stack Overflow 2018 survey.  NodeJS is all over backend job ads.  React vs Angular is the new tabs vs spaces.

Here we have a gem. JavaScript’s author saying that JS was meant to be what BASIC was to C++ and that was the sales pitch for it. This post is not about technicalities of JS. It’s about how our pluralistic ignorance allowed toy language to first become de-facto language in the browser, then work it’s way to the server side and now being used for things such as console emulation and data science.

As the title indicates, I consider JS being popular a bad thing. To begin with, JS is a very bad language. The Wat talk does brilliant job of explaining what is wrong. Refer to these great resources for more details. Reasons for such poor design are obvious when you read all about all the mess that is Javascript’s history here.

To defend the idea of JavaScript against competing proposals, the company needed a prototype. Eich wrote one in 10 days, in May 1995.

This is the problem. This is why we can’t have nice things. Of course, I am under no illusion that the prototype in question has not been re-written hundreds of times. What I am alluding to is the approach that existing practices don’t matter. “Move fast and break things”, as it were. Normal programming languages have a documented history of being in the design stage for years. Usually, a good decade. Those history subheadings in the wiki are practically worded the same way, just with different names and dates in them. It takes a lot of planning and conscious decision making process by well-educated professionals to design a language. Initial design of JS as well as it’s iterations over the years were driven by business decisions, need to dominate the market of browsers, and all that.

It kinda shows. 

The issue is, now that the most popular programming language cannot do basic algebraic operations right, a lot of people start to see this as norm. Popularity is falsely attributed normalcy and here we go. Loads of new joiners to this profession think this is OK. This is normal.

And it kinda has immediate consequences.

Left-pad. Is-even packages having dependencies and a freaking release history! node_modules for your average project having tens of thousands of dependencies. Et cetera, et cetera.

Let’s talk about axios for a moment.

Axios is a http request library. A staple. Axios has 5007 forks and 61,660 stars on github as of now. It’s being used by around 1,5 million projects on github alone.

Suppose you want to make a request and if it fails, log the error for diagnostic purposes. So here is the official boilerplate that developers offer you to do this:

axios.get('/user/12345')
.catch(function (error) {
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
}
console.log(error.config);
});

view raw

axios.js

hosted with ❤ by GitHub

I can’t believe my eyes till this day. If I would’ve submitted something like this as a course assignment in my known-to-nobody-university-from-the-third-world I would’ve gotten epic shaming and an F. It’s 2019 and apparently design patterns and clean code are still magic rituals of shamanic knowledge.

This bug is open and marked as a known bug since 2017. Apparently nested ifs take 3 years to write. I’ll just leave finding equally bad bugs open for 3 years in any other language’s most popular http request library to the reader. Good luck there. Moving on from the topic of axios 😉

This disaster right here. Screwing up map function has to be the Olympics gold for a language designer. Curious detail –  people saying a very coy “JS is weird” are a minority on the comments. There is a fair number of people saying they’ve learned something from the article. I don’t know what would that be, to be honest. Check every function in a language for ways it does not match any other 30 other major programming languages? How exactly .map(f) being different from and, frankly, a broken version of .map(x => f(x)) is useful knowledge? It is vodoo magic, not expected behaviour.

To be a maintainer is an exercise in minimalism. Not to JS world, it seems. New versions are rolled out all the time, whether there is a sense in this or not. 3 year old projects are not easier to rebuild from scratch than to upgrade. Been there, done that. I have never used any JS project that would not have at least a couple warnings about it’s babel version being outdated and soon to be deprecated. Babel has a donation page that says their estimated yearly budget is $308,084. I think for that amount of money we as a community can demand the developers to know what is backward compatibility and respect it’s user base.

OpenCollective is an interesting one to browse, but damn is it depressing. This page shows that estimated yearly budget of Webpack is ONE FREAKING MILLION DOLLARS. Geniuses that decided that putting executable code in configuration files or environment variables need redesigning are good ideas get 10 times more money than this little project called OpenSSL. If OpenSSL is broken, you, your bank, your internet provider, your cloud, your government, your military are all screwed. If webpack is broken, you’ll get gulp or grunt or browserify or whatever toy is fancier at the moment. Yeah it will not be one click migration. Imagine migrating the world off OpenSSL. Better yet, imagine writing functional clone of OpenSSL.  Or hundreds of other projects that are essentially a foundation of modern IT infrastructure, maintained by people who barely get anything donated via some patreon pages or whatnot.

I sound as a person demanding stuff from volunteers on the internet, which is morally bankrupt thing to do. What I am in fact doing is I am making the point that we devaluate the hard work of people writing reliable, well designed software by accepting, as an industry, subpar solutions based on a merit of them running in a browser and having support for emojis. It’s fine for hobby projects and prototyping. It’s ‘ok’, just as PHP is ‘ok’. It works, sometimes. The problem I am having is widespread reasoning pattern – JS is so popular IT HAS TO BE AS GOOD as the other languages and ecosystems. Non sequitur.

JavaScript is the most wanted technology on the market right now. No other language has so much hype, people running around, designer-made logos, t-shirts and 3d printed mascots, funding via Fortune 100 companies and micro-donation services alike. For all this, there has to be a return value. So far, the return value is negative. It dumbs down this entire profession.  JS design committee does not appear to be interested in fixing basic semantics during two decades. I have no idea what they are doing, but clearly, their priorities do not lay in creating programming experience that does not make you want to change profession and pick up gardening. That, in turn creates a culture of “yolo-driven development” that hijacks the whole JS ecosystem, that in turn hijacks the entire profession.

JavaScript is really popular, but really bad. It’s a state that is possible. Only when we agree that this is the reality, we can start fixing the issue.

TL,DR – JavaScript is bad.

 

7 thoughts on “JavaScript is bad.”

  1. I’m with you in principle but please take some time to read through what you write. It reads more like a rambling Tumblr post.
    It’s ironic that your main criticism is that JS was rushed in a blog post that was clearly rushed.

    Liked by 1 person

      1. I do see a trend that Javascript is becoming just another output format for other language compilers targeted for the web. In that same vein, WebAssembly may become the portable object module format that will allow “real” languages like Rust, Kotlin, etc. to be used in the browser and hopefully JavaScript will become a long-forgotten nightmare.

        Like

  2. Great article, completely on point. With increasing severity of browser-based attacks, we cannot afford to dumb programming down even more. We might soon end up with internet full of webservices made by people with few weeks of programming experience a relying on packages like event-stream.

    Knowledge without understanding is useless.

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s