JavaScript is Misunderstood

Many people hate JavaScript for the wrong reasons. Some common misconceptions I see are:

Ok, I admit it. There is some truth to each of these:

But, focusing on the negatives means we have to ignore what makes JavaScript amazing. JavaScript is often the most enjoyable and pragmatic way to bring interactive apps to life. It has everything you need.

The language is expressive. Methods like map, filter, and reduce make complex functionality simple. The destructuring syntax is a joy to use.

Web APIs make awesome projects possible. Want graphics for your game? Check out the Canvas API. Want to add controller support? Check out the Gamepad API. Want to use your piano as input for an app? Check out the MIDI API.

JavaScript was made to work with HTML and CSS, battle-tested domain specific languages. HTML, CSS, and JavaScript combine to elegantly describe user interfaces. Even Qt recognized this. They invented QML to get the benefits of a domain specific declarative language.

Web apps are shareable by default. When something is on the web, any device with a web browser can interact with it. Executables may be more efficient and native, but they lose share-ability.

One of my favorite things to code is snake. It is a simple game, but is any game actually simple to implement? You need to draw graphics, handle non-trivial state, and handle inputs.

Think about programming snake in your favorite programming languages. Will you need 3rd party libraries or frameworks? How many tools will you have to use? How shareable will the result be?

I coded snake in ~50 lines of pretty clear and simple JavaScript. No libraries or frameworks were needed. GitHub pages means I could share it just by sharing the code. Try it out here. If your device has a modern web browser, it will work well.

JavaScript is a huge language with many rough edges. But, some parts are really great. Many people think we need to start over and totally replace JavaScript. I think we should recognize the great parts and build off those.