JavaScript compared with other langauges

JavaScript vs. other languages: Live long and prosper?

When JavaScript first appeared, it was just an extra Turing-complete option that Netscape added to its browser. Many programmers dismissed it as a toy, a vehicle for double-checking the data in the form or adding annoying popup windows. They didn't see the promise. Few noticed the value of its forward-thinking features such as lambdas and functions as first-class objects until it brought them into the mainstream.

It's now more than 20 years later and everything has changed. Web applications are the dominant way that people interact with the computing universe, and JavaScript is the foundation. Even server applications are increasingly written in JavaScript as programmers turn to Node.js for increased speed and the freedom to run the same code on the server and the client. 

Here's a short, bulleted list for comparing JavaScript with some of the other major programming langauges. 

JavaScript compared with C

  • C is compiled in advance. JavaScript is interpreted and sometimes compiled at runtime with a just-in-time (JIT) compiler.
  • C is statically typed. JavaScript is dynamically typed.
  • C requires programmers to allocate and reclaim blocks of memory. JavaScript handles this automatically.
  • C code must be recompiled when moved to a different processor. JavaScript doesn’t need to be.
  • C is designed to work directly with the computer’s memory through pointers. JavaScript hides this power.
  • C is commonly used for embedded computers and applications that require high performance such as operating systems. JavaScript was first embedded only in web pages, but it is finding a new role in server applications developed through Node.js.
  • C offers explicit control of threads, while JavaScript encourages users to juggle multiple jobs by splitting tasks into asynchronous functions that are called when data is ready.

JavaScript compared with Java

  • Java is compiled to a bytecode that is an intermediate form to be run by a JIT compiler. JavaScript was only interpreted at one time but is now often run through a JIT compiler.
  • Java is statically typed, while JavaScript is dynamically typed.
  • Java is strongly typed, while JavaScript isn’t.
  • Java is designed to support large applications with a robust namespace. JavaScript doesn’t offer it directly, so programmers have synthesized it.
  • Java once ran in browsers and servers but is largely limited to servers today. JavaScript once ran only in browsers but is now increasingly used on the server side too.
  • Both Java and JavaScript support many other languages. Cross-compilers convert many languages to run on Java’s JVM or JavaScript engines.
  • Java 8 now includes a mechanism for embedding JavaScript so Java can leverage several of JavaScript's benefits.
  • Java gives the programming explicit control over threading. JavaScript hides much of this with its call-and-response function structure.

JavaScript compared with C#

  • C# is compiled to a bytecode that is an intermediate form to be run by a JIT compiler. JavaScript was once only interpreted but is now often run through a JIT compiler.
  • C# is statically typed, while JavaScript is dynamically typed.
  • C# is strongly typed, while JavaScript isn’t.
  • C# has LINQ, a powerful .NET component that adds native data querying capabilities, but JavaScript has separate libraries that can cover this functionality, one being Underscore.js.
  • C# gives the programming explicit control over threading. JavaScript hides much of this with its call-and-response function structure.
  • C# has operator and conversion overloading. JavaScript does not.

JavaScript compared with Python

  • JavaScript was originally designed to support HTML pages in the browser. Python was made to run from the command line to support servers (and desktops).
  • Both languages are now supporting larger communities. Python is popular as a data processing language in the social sciences. JavaScript is found now on servers and other locations.
  • JavaScript uses curly brackets to designate blocks of code. Python uses indentation and whitespace.
  • Python offers flexible parameter blocks for methods, while JavaScript insists that all parameters must be specified.
  • JavaScript code is often driven by events such as mouse clicks or keystrokes. Python responds to function calls.
  • Many Python libraries are focused on data processing and analysis, while many JavaScript libraries are designed to manipulate HTML in the browser.

JavaScript compared with PHP

  • Both are scripting languages that were originally interpreted at runtime but are now often transformed by a JIT compiler.
  • Both offer dynamically typed variables.
  • In the beginning, PHP was designed for servers to assemble HTML files and JavaScript ran inside the browser on the client. Now JavaScript is also building HTML files on the server too.
  • PHP is rarely used for anything but assembling HTML. JavaScript is the foundation for increasingly complex interfaces in the browser and server-side stacks integrating business logic and databases.
  • PHP is a relatively simple language focused on retrieving information from databases and formatting it as HTML. JavaScript is becoming a more general language used for both browser interaction and more general computation.

JavaScript compared with Ruby

  • JavaScript was once limited to running in the client’s browser, while Ruby ran on the server with the Rails framework.
  • JavaScript running in Node.js on the server is borrowing many ideas from the Ruby on Rails framework.
  • Both Ruby and JavaScript are dynamically typed.
  • JavaScript uses curly brackets to delineate blocks, while Ruby uses the keyword “end.”
  • JavaScript borrows much of its syntax from Java and C, while Ruby borrows more from Perl and Smalltalk.
  • JavaScript is becoming a general-purpose language, while Ruby is generally limited to server applications using its Rails framework, although some administrators prefer Ruby for their server-supporting command-line applications.

As you can see, JavaScript is very different from many of the other popular languages. Its initial version was written in just 10 days, but it had a lot of forward-thinking innovations that helped it survive into the current decade.

Despite its many warts, it looks like it will continue to be a primary language for front-end developers as long as it continues to be the only language that all browsers understand. 

Any comparisons or addendums you'd like to add? Share them in the comments. 

Topics: App Dev