Once upon a time in California, a talented computer scientist named Brendan Eich wrote a brand new programming language. The legend wants that his creation took about 10 days of work and it was called 'Mocha'.
At that time, Brendan was working for Netscape, one of the top companies in during the '90s. The company decided to ship JavaScript, which they had renamed from 'Mocha' to 'LiveScript', in its newest browser by introducing it as the 'the scripting language' for the web.
A very popular language at that time was Java, so once again, the language created by Eich was renamed to JavaScript with the hope that a name similar to the 'bigger brother' Java would help it grow in popularity among web developers.
During the coming years JavaScript has become an independent language with its own specification, named ECMAScript, and it has no relation with Java. Actually, its name has generated confusion among recruiters and other professionals.
The Language
In JavaScript language, programs are called scripts and we can use them to make web pages come alive by writing them inside an HTML page and making them run automatically as the page loads.
Scripts are executed as plain text and don't need any compilation to run. In fact, JavaScript is considered to be a high-level programming language that is supported by all modern web browsers.
A 'high-level programming language' refers to the higher level of abstraction from 'machine language'. Instead of writing instructions that can be executed directly by a computer's CPU (central processing unit), in JavaScript we deal with variables, arrays, objects, boolean expressions, functions, loops, threads, and other abstract concepts.
Thus, JavaScript's capabilities depend mainly on the environment it runs in. If used in a web browser, JavaScript takes care of several tasks like:
- adding new HTML to a page or updating existing code
- updating styles
- reacting to actions triggered by the user (like mouse events and key presses)
- using AJAX to make requests over a network
- in addition to dealing with the local storage (getting and setting cookies)
- and many more.
Code written in JavaScript can execute not only in the browser, but also on the server, and on any device that has a JavaScript engine. A JavaScript engine is a computer program that executes JavaScript code.
More precisely, an engine read ('parses') the script that we, as developers, write. The script is converted ('compiled') into machine language that will run.
There are several different engines out there, but the most famous are:
- V8 used in Chrome and Opera
- SpiderMonkey used in Firefox
- ChakraCore used in Microsoft Edge
- JavaScriptCore used in Safari.
JavaScript today
The early days, when JavaScript was simply making a page come alive are gone. Flash forward 25 years and JavaScript is the world's most popular programming language (according to GitHub and Stack Overflow).
Today, JavaScript is one of the core technologies of the web, along with HTML and CSS and it's being used in fields that go beyond the web, like machine learning, virtual reality and even in robotics and IoT platforms like Johnny-Five.
I'd say there are plenty of reasons to get to know JavaScript better!