JavaScript does not annoy me anymore

Getting around typical JavaScript pitfalls.

I used to be hardcore C++/C guy. Always looking down at dynamic scripting languages (aka Perl, JavaScript), even when I used it to glue all the different parts together. Then I moved on to front-end development using JavaScript. I did not go to js directly, instead using CoffeeScript as a nice bridge.

JavaScript used to annoy me: parentheses, misspelled variables, long build / test in the browser cycle, etc. Luckily for everyone, several tools emerged that smoothed the rough edges

  • Node provides an excellent execution environment without need for the browser
  • jslint / jshint / other static analysis tools catch most of the errors
  • text editors, like my favorite SublimeText, open/close parentheses automatically, even showing me the current matching and outer pair
  • setting up tools to run any build and test command on file changes under node is trivial by using tools like nodemon and grunt-watch.
  • accidental global variables is easy to prevent using function closures.
  • I prevent callback hell and pyramid of doom using promises and lately using generator functions

Most surprising thing that does not annoy me: I do not miss C++/C#/Java classes. While I used js prototypes at first, today most of my projects are semi-pure functional pipelines, transforming data in response to events using my favorite lodash library. There might be some state, but it is hidden inside separate modules using function closures.