JavaScript — Why All The Hate?

I don’t really get all the hate and whining from some people about Javascript. I love Javascript. It won’t run everything or solve every problem but it is the closest we have come to “run everywhere” — please do NOT mention java.

With JavaScript, you can write applications that work:

  1. in your browser (pretty much ALL of them)
  2. on your phone and tablet (e.g. React Native, Cordova)
  3. on your desktop (e.g. electron runs on mac, linux and windows)
  4. on your server i.e. node
  5. and even in your database e.g. mongo db

You don’t need to download a 4 gigabyte IDE to create a hello world, you don’t need to wait 30 seconds to compile and run your app, all you need is a text editor.

Sure javascript has flaws but so does every other language out there but nothing comes close — not even by a mile — to the reach and flexibility of javascript.

I love the innovation (and explosion) of javascript tools, frameworks and libraries. I know it can get tiring but it’s fun and guess what, you don’t have to learn ALL of them.

With that said, can we please stop creating “languages” on top of javascript and please stop using them in your projects. We already have enough: TypeScript, Elm, Coffeescript and others. I highly recommend you do NOT use any of them in your projects.

I will explain why but first let me say how much I appreciate the diversity in choices and most importantly how thankful I am to the people that create these awesome tools and “languages”.

I was a huge coffeescript fan. I decided to use it for a project a few years back and as the project grew I quickly realized that it was the worst decision I made and six months into the project we converted everything over to Javascript. Here are some reasons why that was a bad decision:

  1. I had to setup another build step to “compile” it back to javascript — not a huge deal but it can be a pain some times.
  2. It was hard to debug since what you see in the browser is different than what you have in your coffeescript files — for the most part, it is very readable but you still have to perform a mental translation.
  3. The biggest problem by far is the learning curve for every new developer that joined the team — yet another thing they had to learn to ramp up
  4. Most code samples online were 99% in javascript
  5. The team started losing some of their javascript skills, slowly, javascript code started to look foreign and we wanted to see everything in coffeescript.
  6. We didn’t keep up with all the advancement in javascript e.g. ES6 — arrow functions, deconstruction and so on.
  7. We couldn’t just put a few lines of code directly in a script tag to test some stuff and if we did, we had to do it in javascript and later “translate” it back to coffeescript.

Although, I didn’t play much with TypeScript or Elm, I would assume they would have similar problems.

RE: TypeScript — really cool concept and I get some of the benefits but why are we forcing a dynamic language to “act” static? C# is jumping through hoops to act more dynamic and now we are jumping through hoops trying to make javascript act more static. WTF!!!

TL;DR

  1. Stop hating and start loving Javascript
  2. Stop using another language on top of it
  3. Embrace the dynamism of Javascript

Originally published at Emad Ibrahim.