Is JavaScript Better than Java, C# and C++ (A.K.A. Why JavaScript is Like a Cockroach)

Okay, let’s get the controversial part resolved right out of the gate.  Why is JavaScript like a cockroach?

  • Cockroaches are practically invincible — they can withstand ten times the nuclear radiation humans can and they can survive for a week if their head gets cut off.
    • Corollary: several of the worlds largest corporations have attempted to kill off JavaScript and none have been successful.
  • Cockroaches are fast –proportionally they are three times faster than a cheetah.
    • Corollary: JavaScript enables very rapid development.  It’s mixed-paradigm (functional with object-oriented characteristics), dynamic (duck) typing and enormous developer community allow for very rapid development
  • Lots of people think cockroaches are ugly and try to kill them.
    • Corollary: Identical.

Obviously my use of cockroaches as an analogy gives the impression I don’t like JavaScript.  This, however, is completely untrue (albeit I do dislike cockroaches).  I thoroughly enjoy modern JavaScript and find it to be an extremely powerful language.  One I choose to work with more frequently than Java, C# or C++.

Is JavaScript better than C#, Java or C++?  Obviously this is a nuanced question that deserves a nuanced answer like: it depends on the problem domain, performance and platform requirements, etc.  But, I’m not going to give a nuanced answer.  I’m just going to say: yes.

Why?  JavaScript has several benefits over the other languages:

  • Paradigm Flexibility: JavaScript supports aspects of functional programming.  It also supports object-oriented capabilities through the use of closures and prototypal inheritance.  While the other languages started out class-based and migrated toward functional, JavaScript always supported functions as first-class members and has migrated toward class-based object-oriented syntax.
  • Extreme Object Extensibility: JavaScript supports duck typing, prototype modification and treats all objects as associative arrays which allows for dynamic insertion of functionality and data.
  • Ubiquity: Based upon data from GitHub and StackOverflow, JavaScript is the most actively used language.  This leads to:
  • Cross-Problem-Domain: Thanks to node.js, electron and every browser ever invented, JavaScript has strong support for developing services, front-end web applications and native applications.

While the points I’ve made above are true, I wrote this blog somewhat tongue-in-cheek.  In the real world, your choice of language and tech stack will depend upon many things: problem domain, risk tolerance, schedule and cost budgets, development team composition, etc.  But, don’t discount JavaScript as a viable option just because it’s got warts.  To use a carpentry metaphor: if your toolbox can only hold one hammer–JavaScript is the biggest, baddest hammer in the shed.

TL;DR

If you could only use one programming language for the rest of your life–choose JavaScript.