Dev

What is JavaScript? The full-stack programming language


JavaScript is a wildly popular interpreted scripting language that was the most in-demand language of 2023, with 29% of job offers requiring programming experience with JavaScript or TypeScript. There are various reasons for JavaScript’s success, starting from the fact that it’s an open standard, not controlled by any single vendor, with numerous implementations and a syntax that is easy to learn.

Just about anything interactive or animated on a webpage today is rendered in JavaScript. Thanks to server-side frameworks such as Node.js, Deno, and bun, the language also extends beyond the browser. It is used to write code for anything from clients to servers to cloud-based applications.

This is an overview of JavaScript, including a brief history, what kinds of applications it is used for, tools for working with JavaScript, and resources for learning JavaScript.

A brief history of JavaScript

As its name implies, JavaScript is a scripting language. Traditional languages such as C++ are compiled before they’re run into executable binary form, with the compiler checking for errors in the entire program before the process is complete. Scripting languages, by contrast, are executed one line at a time by another program called an interpreter. Scripting languages started out as a series of shell commands used to execute other programs. Their flexibility and ease of use made them a popular type of programming language in their own right, and languages like JavaScript became important with the rise of the web.

Many developers new to JavaScript wonder about the Java part of its name. The short story is that Java and JavaScript emerged during the same historic moment, and both were key to the birth of the web. Their history is intertwined, but the two languages are separate. Brendan Eich, JavaScript’s creator, explained why JavaScript was considered an important complement to Java in the original Netscape browser:

There were people who argued strongly that Java’s fine for programmers who build components, but there’s a much larger audience of people who write scripts or maybe copy a script from somebody else and tweak it. These people are less specialized and may be paid to do something other than programming, like administer a network, and they write scripts part-time or on the side. If they’re writing small pieces of code, they just want to get their code done with the minimal amount of fuss.

Originally called LiveScript, the language was created with syntax that was superficially similar to Java in order to tap into the emerging Java developer community. Even though its usage grew in tandem with Java and early web development, JavaScript was long considered a lesser sidekick to the more robust Java programming language.

In 1997, the ECMA (European Computer Manufacturers Association) issued a standard defining the language that anyone could implement. The reason for this move was that “Java” remained a Sun trademark that only Netscape had a license to use. The new, standardized version of JavaScript was dubbed ECMAScript, but in practice, most people know the language as JavaScript.

What is JavaScript used for?

JavaScript was developed to help create interactive websites, and this remains one of its primary uses today. Developers incorporate JavaScript into their website code, where it is executed by the interpreter built into the user’s browser. The JavaScript code creates or modifies HTML on the fly to produce dynamic content and interact with back-end data stores. When used this way, JavaScript is called a client-side language, with one of its most lucrative applications being mobile games. Server-side frameworks like Node.js extend JavaScript for more scalable and event-driven applications.

Advantages of using JavaScript

You won’t hear anyone arguing that JavaScript is a perfect language, but it is a very useful one. It’s easy to write workable code quickly in JavaScript, and while interpreted languages often don’t perform well compared to compiled code, JavaScript has a special advantage here because it was initially created for web browsers. Three of the biggest software companies in the world—Microsoft, Apple, and Google—compete to produce high-performance JavaScript interpreters. As a result, JavaScript is a remarkably robust and scalable language, even given its humble beginnings.

Once non-browser viable JavaScript runtimes became widely available, the army of web developers well-versed in JavaScript suddenly found themselves crowned as full-stack developers. The JavaScript tooling ecosystem boosts developer productivity with code that gets the job done from the browser to the server. Due to its popularity, the language is also frequently updated. It’s a classic example of a virtuous cycle of popularity driving adoption.

JavaScript libraries and frameworks

You’ll sometimes hear people refer to vanilla JavaScript. This, in a nutshell, means you’re working with an application that was written in JavaScript from the ground up. This is fine for small bits of functionality, but once you start working at scale, it quickly becomes untenable, as any enterprise developer will tell you. Most JavaScript developers make frequent use of the vast array of available JavaScript libraries—prewritten third-party code, usually free and open source, that solves a common problem and can be integrated into your project. (The ECMAScript standard refers to JavaScript modules, but library is the more commonly used term in practice.)

Most JavaScript developers turn to libraries for basic application plumbing rather than reinventing the wheel. There are also frameworks, which are collections of libraries designed to work together to provide the scaffolding for enterprise-scale applications. Using frameworks lets developers focus on the technical aspects of their programs. Probably the most famous JavaScript framework is Angular. Others include React and Vue.

TypeScript: A superset of JavaScript

An important aspect of the JavaScript ecosystem is TypeScript, which is similar to JavaScript but has features that the basic language lacks, like strong typing of variables and other data structures. TypeScript and languages like it are often designed to bring to JavaScript concepts that make it easier to build sprawling enterprise-scale applications efficiently; TypeScript in particular was created at Microsoft when the company was developing a web-based version of its flagship Office suite.

TypeScript is said to be a superset of JavaScript because its syntax includes everything in JavaScript, and then some: good JavaScript is always good TypeScript, but TypeScript has syntax that isn’t part of JavaScript. TypeScript code is transpiled into ordinary JavaScript, allowing it to run in browsers and on standard JavaScript runtimes. Learn more about the similarities and differences between TypeScript and JavaScript.

Resources for learning JavaScript

If you are serious about becoming a JavaScript developer you’ll want to go deeper than this article. The W3Schools JavaScript tutorial is great for your first dive into JavaScript syntax. Here are some additional articles and tutorials to help you get started:

JavaScript Snake is a live example of what you can do with JavaScript. It’s a classic game that can be built to run in the browser using only JavaScript, HTML, and CSS. This tutorial from Panayiotis Nicolaou shows you how.

Get started with JavaScript

Are you ready to start playing around with JavaScript today? Because it’s an interpreted language, you don’t need to download JavaScript. You can just fire up your favorite text editor (or better yet, a JavaScript editor or IDE) and start typing code! A JavaScript interpreter is built into any web browser that executes commands, so you can simply embed your JavaScript into an HTML document and load it up to test.

If you want to run JavaScript code in a desktop environment—which will give you access to the filesystem, among other things—then you can download Node.js.

Copyright © 2024 IDG Communications, Inc.



READ SOURCE

This website uses cookies. By continuing to use this site, you accept our use of cookies.