JS Everywhere Paradigm - Part 1 - History and applications

JavaScript has been with us since 1995 and it really took over the Internet. Starting as a simple scripting language to make early websites more dynamic, it finally became a foundation of modern web applications. Nowadays, it is not only possible to build beautiful websites with JS but also to write backend, create desktop and mobile applications, and even develop and train AI.

In this blog post, I will tell you the history of JS, why it faced so much flak and finally, I will describe a few tools that will allow you to build a modern application using just a single programming language.

A brief history of JS

Before JS became the most popular language in the world, it started small, as a scripting language created in just 10 days for the brand new browser - Netscape Navigator. Before JS days, websites were simple static pages that could not be changed after the server response was received. To overcome that limitation, in 1995, LiveScript was created and a few months later changed its name to JavaScript.

Microsoft came into play during this time and released its own browser: Internet Explorer. Microsoft’s team has reverse engineered the Navigator interpreter to create its own language - JScript, released in 1996. JScript and JavaScript had many differences and it became difficult to write frontend code that would work in both browsers. In late 1996 Netscape submitted JS to ECMA, an international organisation that works on computing standards. Finally, in 2009 a single standard for all browsers was created: ECMAScript 5. Before that, coding frontend could have been a real struggle because developers needed to check the support of every JS feature in all major browsers. The problem still exists but is much less of an issue than it used to be.

A huge milestone in JS history was the release of the V8 engine developed by Google. It is an open-source engine written in C++ that tremendously improved JS performance by providing Just in Time (JIT) compilation. That method basically compiles some parts of code during runtime which was a huge performance boost for JS interpretation in browsers.

At this time, JS could only run in web browsers so JS was used purely as a frontend language for creating interactive websites. Everything changed in 2009 when NodeJS was released. NodeJS is an open-source runtime environment for JS that uses V8. It allows you to run JS code on any machine that has NodeJS installed.

Is JS everywhere?

Knowing the crazy history of JS, we can discuss how it is used. In the introduction, I said that it is possible to build nearly every type of application using JS; in this section, I will present to you some use cases with examples of technologies to use for each one.

Frontend

Frontend is the most well known use case for JS. There are dozens of frameworks out there that help you develop visible parts of your system - so many that it became a meme. My favourite example is a website that shows how many days have passed since the last framework was published.

Screen from website: https://dayssincelastjavascriptframework.com

Jokes aside, there are many great frameworks available, starting from the mainstream like React, Angular (TS) or Vue to less known ones like Aurelia. All these frameworks allow developers to build complex frontend applications with great UX and UI. What is more, there are many ready-to-use tools that help you develop your websites faster. To show you how many libraries and tools are out there, let’s take a look at npm. Npm is an online package repository that allows sharing JS code. Currently, there are over 1 million packages available. Of course, some of them are more useful than others but still there are plenty of options to choose from. There are module bundlers (e.g. Webpack), CSS frameworks (e.g. TailwindCSS) and ready UI components (e.g. datepickers, calendars, tables and much more). If you like to build applications from ready-made blocks, then JS is the way to go.

Mobile

Nowadays, both web and mobile frontend can be created with JS frameworks. For example, thanks to React Native, it is possible to develop applications for Android and iOS. The name is not a coincidence, and React Native allows developers to reuse React components. The interface of React Native is the same as React; however, it does not operate on the DOM but with a native platform it runs on.

Another technology that allows the creation of mobile applications is PWA which stands for Progressive Web Applications. In PWA, developers use common web technologies like HTML and CSS to build an application. When such an application is released, the user can use it via browser and install it on a device. The main difference between traditional websites and PWAs is the fact that PWAs allow not only installation but can also work offline.

Backend

Since NodeJS came into play, JS stopped being a pure frontend language and started to get more and more attention in various other fields. Right now, it is possible to write your application’s API with JS and consume it on the frontend. The most well known server-side JS framework is ExpressJS, released in 2010. After that, many new frameworks were created: Koa - a backend framework developed by ExpressJS team, Meteor - a framework that allows to develop full stack applications and NestJS, which is written in TypeScript and follows Angular architecture.

Desktop

If you need your application to be installed on a desktop, then JS also provides such a possibility. The most well known desktop framework is Electron. It allows developers to build desktop UI applications using HTML and CSS. Thanks to that, it is not necessary to have separate desktop teams that develop in different languages and, what is more, some of the styling components can be reused. Additionally, Electron is not the only tool to do that; as already mentioned, PWAs allow users to install applications on their desktops too.

Upgrade your tech game with us

Games and 3D

Not only business applications can be built with JS. Nowadays, you can create games and even VR applications using JS. There is WebGL, which is a JS API for rendering 3D graphics in a web browser. If the name is somehow familiar to you, then you are right because it is based on OpenGL and provides a similar API. WebGL is a fairly low-level API that is a base layer for other higher-level libraries that allow developers to create games faster and easier. One such example is Pixis.JS, a fully fledged game engine that enables developers to create games and render them in a web browser.

Finally, there is A-Frame that provides an API to create VR applications that are rendered in web browsers. The core of A-Frame is an entity-component engine that wraps around three.js (a library that provides ready API over WebGL). It speeds up and simplifies building games and VR apps using WebGL. A-Frame supports all major headsets.

AI

I already told you about business and entertainment usage of JS; however, there is more: scientific usage. It is possible to develop AI using JS with some cutting edge technologies. The traditional way to deal with machine learning is to use Python, and the most known library to build ML models is Tensorflow. In 2018 Google released Tensorflow for JS. Even before that, there was Brain.JS that enabled machine learning in browsers. Thanks to these, scientists can build, learn and test using browsers and easily share their projects with all users.

What is more, there are wrappers like ml5js that speed up the process of developing models. The JavaScript community is huge which helps develop such solutions.

To sum up

As you see, there are many possible applications of JS and the language itself has a pretty interesting history. In the next part of this post, I will say more about why JS is a language that can be used anywhere and I will tell you why many developers get chills when you ask them to use JS.

Sources and docs

Share the happiness :)