From Javascript to Nodejs

Written by Dave Johnson

If Javascript can be used to do it, as Jeff Atwood once said it will eventually be used to do it.

This quote demonstrates the immense popularity of Javascript; that MaGyver-like general purpose programming language that many of us have loved to hate (or at least moan about) through the years!

In this article we’ll be looking at the journey through the days of Javascript up to the phenomenal era of Nodejs, enjoy!

The beginnings of Javascript.

JavaScript grew out ot the 1990s. The language was created by Brendan Eich in 1995, and initially released as part of the Netscape Navigator web browser and was designed to enable web developers to create dynamic, interactive websites.

It was quickly adopted by developers, and soon became the language of choice for web development. Since then, JavaScript has become the most widely used language for web development and is now the de facto standard for client-side scripting. The language has proven so useful that it now supported by all major web browsers.

Some of the benefits of javascript were and still are:

  1. Increased interactivity: JavaScript can make web pages more interactive by responding to user actions.

  2. Improved design: JavaScript can be used to improve the design of webpages, such as adding dynamic content, interactive elements, and animations.

  3. Increased speed: JavaScript can improve the speed of webpages by reducing the amount of time it takes to load content.

  4. Increased accessibility: JavaScript can make webpages more accessible to people with disabilities.

  5. Reduced server load: JavaScript can reduce the load on web servers by running code in the browser instead of on the server.

  6. Improved security: JavaScript can help to protect web pages from malicious attacks by validating user input and preventing malicious code from executing.

So what were the drawbacks?.

Due to it’s client side nature, it’s main advantage, there were some drawbacks:

  1. Client-side security: JavaScript is primarily a client-side language, so it cannot be trusted for sensitive operations as the source code is viewable by the user.

  2. Browser compatibility issues: Different browsers interpret JavaScript differently, so it’s difficult to guarantee the same behavior across all browsers.

  3. Memory management: As JavaScript is a client-side language, there is no built-in garbage collection, so it’s up to the developer to manage memory and prevent memory leaks.

  4. Single-threaded: JavaScript is single-threaded, so it can only execute one line of code at a time. This can lead to performance issues.

So it was only a matter of time before a version for the server side came along…

Enter Nodejs!

Node.js was initially created in 2009 as an open-source server environment that uses JavaScript as its scripting language. The main goal of Node.js was to provide an easy way for developers to build fast, scalable network applications.

It was created by Ryan Dahl and became a huge success due to its scalability, speed, and ability to handle multiple concurrent connections.

The development of Node.js was driven by the need to improve upon traditional web development technologies. Node.js was designed to be more lightweight and efficient than other web development technologies.

It also introduced a new way to write server-side code using JavaScript, allowing developers to write code that ran both on the server and the client.

Node.js has since become a popular platform for building web applications, powering websites like Netflix, PayPal, and Walmart. It is also used in IoT applications, robotics, and other real-time applications.

Node.js has been instrumental in helping create a new generation of web developers who are comfortable working with both front-end and back-end technologies.

Below is a typical Nodejs “main function” file initiatng the application.

const http = require('http');

const hostname = '';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World\n');

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);

so what’s in store for Nodejs?

Node.js is here to stay and is already a popular choice among developers. As the technology continues to evolve and become more powerful.

Node.js is expected to become even more popular and ubiquitous. It’s likely to become the default choice for developing web applications and services, as well as more specialized applications such as IoT and machine learning.

With the increasing demand for real-time applications and the growth of cloud-based services, Node.js is positioned to continue to be an important part of the future of software development.