Node.js #01 – JavaScript History


JavaScript Language Development

JavaScriptJavaScript, originally named LiveScript, was developed at Netscape in 1995. The language’s purpose was to allow web pages to exhibit dynamic behavior. LiveScript had no relationship to, or shared history with, the Java programming language. The language, however, was designed to be “consistent” in style with Java. LiveScript was almost immediately renamed to JavaScript for marketing reasons. JavaScript is frequently abbreviated as “JS”. Along with HTML and CSS, JS is one of the three core display technologies of the World Wide Web.

Almost immediately after its initial release, JavaScript language standardization efforts began. These standardization efforts were thwarted by the lack of cooperation between the major Web Browser vendors. Netscape, Microsoft, and others were engaged in a monumental battle for strategic dominance in the browser market. These vendors did not want an Open Standard, they wanted control of the marketplace. These was a time when many web pages only displayed properly in certain browsers due to the lack of standardization.

The JS language received a significant boost in 2005 with the development of Ajax. Ajax was based upon JavaScript and had a major impact on web performance. This resulted in an explosion of JS frameworks and libraries to support Ajax and other programming initiatives. The newly developed libraries included, amongst others, JQuery and the Dojo Toolkit. These developments, in turn, spurred the increased usage of JS.

The usage of JS in Web Browser environments came to be called “Client side”. The increased usage of Client side JS stimulated renewed interest in developing other runtime environments. In 2009, the CommonJS project was launched to standardize these “Server side” runtimes. Also in 2009, Ryan Dahl developed Node.js as a Server side runtime. In 2010, the “npm” (the letters are NOT an acronym) package manager for Node.js was developed independently. By 2015, the Node.js Foundation was put in place to provide a common Open Source community. Currently (April 2018), there are currently over 650,000 JS packages available through npm.

JavaScript has come to be seen as one of the “foundational” languages for modern computing. All modern Web browsers support JavaScript natively, without the need for a plug-in. The use of JS to create dynamic behavior is also termed Dynamic HTML, or DHTML. Its dominance in Client side computing is complete. 95% of 10 million most popular web pages use JS. JS is available as a Server side runtime from all of the major Cloud Vendors (IBM, AWS, Microsoft, etc.) It has been extended by multiple frameworks, including: React (Client-side), Node.js (Server-side), Node-Red, and LoopBack.


JavaScript Language Overview

JavaScript is an interpreted language. It has no native Input/Output (I/O) capability. These I/O functions are left to the runtime environment to provide.

JavaScript is an Object Oriented language. All variables must be declared. All variables are objects. If more than one value is assigned to a variable, the object will contain name value pairs. A brief overview of the language follows below.

Some of the rules for the JavaScript language are:

  •   JavaScript ignores whitespace.
  •   JS commands are terminated by a semi-colon (“;”).
  •   Commands can be combined into blocks, delimited by braces (“{“, “}”).
  •   Strings are surrounded by single (‘) or double (“) quotes.
  •   Variable names (identifiers) are case sensitive.
  •   Comments on a single line begin with “//”.
  •   Comment blocks begin with “/*” and end with “*/”.
  •   Variables defined outside of a Function are global in scope.
  •   Variables defined inside of a Function are only visible in the function.

Some of the JavaScript commands (keywords) are:

  break   Terminate a switch or a loop.
  catch   Defines error handling for a block.
  continue   Terminate current iteration of a loop.
  do   Execute a block of commands.
  else   Defines a block when “if” is false.
  for   Terminate a switch or a loop.
  function   Defines a function.
  if   Defines a condition to execute a block.
  new   Creates a new object instance (e.g. var x = new className();).
  return   Exits a function.
  switch   Defines a set of conditional blocks.
  try   Defines a block needing error handling.
  var   Define a variable.
  while   Defines a condition to repeat a block.

Some of the JavaScript assignment & arithmetic operators are:

  =   Assignment (Assign value on the right to the variable on the left).
  +   Addition (Numeric). Concatenation (String).
  –   Subtraction.
  *   Multiplication.
  /   Division.
  %   Modulus (Remainder).
  ++   Increment (Add 1).
  —   Decrement (Subtract 1).

Some of the JavaScript comparison & logical operators are:

  ==   Equality (value).
  ===   Equality (value & type).
  !=   Inequality (value).
  !==   Inequality (value or type).
  >   Greater than.
  <   Less than.
  >=   Greater than or equal to.
  <=   Less than or equal to.
  &&   Logical “And”.
  ||   Logical “Or”.
  !   Logical Negation (“Not”).

Some of the ways objects are used include:

  •   Object “methods” are implemented as functions within an object.
  •   The value the Object “method” returns is referenced as if it were a variable.

Angular Client-side Framework

AngularAngular is an Open Source web application framework maintained by Google with the support of a broader community of developers. The original release of Angular (version 1) is referred to either as AngularJS or Angular.js.  The current (version 2) release of Angular is referred to as simply Angular.  The Angular framework can best be understood as an “extension” to HTML.  The Angular framework implements a Model-View-Controller (MVC) paradigm to simplify the management of individual web pages.  This framework leverages custom tags built into the HTML to be rendered.  These tags “bind” elements of the HTML page to JavaScript objects.  These objects can then be manipulated through JavaScript code before being converted into the final HTML page to be rendered by the browser.

Angular is added to a HTML page through the “” tag.  These tags extend HTML attributes with “Directives” and bind data using “Expressions”.  Some example Angular Directives are:

  • ng-app  (define an Angular JavaScript application).
  • ng-model  (bind HTML controls (input, select, textarea) to JavaScript data).
  • ng-bind (bind JavaScript data to the HTML view).

Angular Expressions are written inside double braces (“{{ JavaScript expression }}”).  Angular will replace the expression with the resulting data described by the expression.


React Client-side Framework

ReactReact, also referred to as React.js or ReactJS, was first developed at Facebook in 2011. It was used in Instagram the next year (2012) and then the following year (2013) it was placed into Open Source. It has become a widely used Client-side JS library. React is not a full JS framework, rather the library facilitates the rendering of HTML pages. This allows the developer to decompose an entire HTML page into a series of individual components. Each of these components can then be individually programmed and implemented.

The React library thus bridges the gap between a “component” view and the actual HTML to be rendered. While other language environments already supported this kind of decomposition, it was desperately needed in the HTML world. Java Swing, as an example, had implemented this approach more than 15 years earlier. Nevertheless, the capability was seriously needed in the Web developer world and the React library rapidly became a widely used extension to a Client-side JS environment.

The React community is a vibrant and healthy, which major enhancements continuing to be released. Finally, it should be noted that React is not necessarily a Client-side only library. React can also be used in a Server-side environment. This is obviously only useful if the Server-side is “serving” up HTML code. React would not be used, for example, in a Node.js server providing RESTful Web services.


Node.js Server-side Runtime

NodeJSNode.js is a Server side runtime for JavaScript. This runtime was first developed in 2009 and is currently supported by all of the major Cloud vendors (IBM, Amazon, Microsoft, etc.). In 2015, the various branches of the Node.js community converged into the vendor-neutral Node.js Foundation.

The Node.js runtime is single-threaded. This means that the single node.JS CPU thread must handle all function request calls from all of the active JS processes. In order to accommodate this, all Node.js function calls are non-blocking. Call-back notifications are used for I/O. One of the implications for this is that Node.js is better suited for horizontal scaling than for vertical scaling. This is an ideal fit, of course, for modern containerized environments.

Node.js software releases happen twice a year, in April and in October. April releases have even numbers and October releases have odd numbers. The April 2018 release is numbered 10.0. When a release has an odd number, the preceding even number release goes into Long Term Support (LTS). This LTS phase last for 18 months and is followed by a 12 month “Maintenance” phase. Thus, even number releases have a 3 year (36 month) support cycle.


Node-RED Server-side Runtime (Node.js extension) & Framework

node-REDNode-RED was originally developed by IBM. It is both a visually based programming tool and a runtime. It allows both visual and JS programming. The Node-RED runtime is built on top of Node.js. In 2016, IBM contributed Node-RED to the JS Foundation project, so it’s now Open Source.

Node-RED is a supported development & runtime platform in the IBM Cloud, Amazon AWS, and Microsoft Azure. Node-RED is also supported on a number of devices (Raspberry Pi, Android, and others) and is beginning to be more widely used in the IoT world. Its design was similar to other successful IBM visual programming environments such as IBM Integration Bus and Process Manager. The design leverages common patterns and code frameworks to accelerate development. It also leverages automated tooling to make it easy to migrate from development to deployment.

An example of a Node-RED development workbench is shown in the illustration below. With over 225,000 packages in the Node.js registry, it’s easy to extend Node-RED. Node-RED flows are stored in JSON so they’re both easy to export and easy to collaborate with. The tried and true use of Connector nodes make it easy to develop an interface. Reuse is automatic, with only configuration required.

Cloud-Node-RED-IDE


LoopBack Node.js Framework

LoopbackStrongLoop began in 2013 as a Node.js provider and framework developer. They were acquired by IBM in 2015. The IBM StrongLoop team continues to develop three important Open Source APIs for the Node.js community. These APIs are: LoopBack, API Microgateway, and Open API.

LoopBack is an Open Source framework that extends Node.js. It allows the creation of REST APIs with little to no coding. In addition to REST, LoopBack also provides support for the SOAP protocol. LoopBack also provides database access support for both Relational Databases (SQL) and MongoDB. Finally, the framework provides other extensions to support more complicated interactions and security (e.g. OAuth 2.0).

The LoopBack framework thus extends the Node.js capabilities in the IBM, Google, and other Clouds. The Open API and API Microgateway frameworks continue to be supported but have been merged into other IBM products (API Connect).


First in Series.     Previous.    Next.     Last in Series.


Note: This Whitepaper was first published by this author in the IBM Middleware User Community (May 2018).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s