Why Javascript Is Called Lightweight Programming Language?

Javascript is a scripting language. It has functions, loose typing, dynamic objects, and object literal notation. The functions of javascript are lexical in nature. Most programming languages support strong typing because errors can be detected easily, but javascript is loosely typed, which makes it difficult to locate errors.  

Javascript is a programming language that supports literal notation to create objects. In Javascript, objects are created with the help of their components. Javascript objects can have properties similar to that of other objects. However, Javascript uses global variables, and many times this becomes a problem in maintaining the function state.

Javascript complies with ECMAScript specifications. Javascript is a language that is compiled just in time. In javascript, programming can be done in different paradigms, and code blocks beginning and end are marked with curly brackets.

Javascript is the most used language to build web-based applications. Javascript is an event-driven programming language and supports a programming style that is imperative. Javascript can work with strings, dates, regular expressions, regular data structures, and DOM.

Javascript is used in browsers,  servers, and other applications. Javascript has a large number of libraries and frameworks used to develop web-based applications. In addition, Javascript can be used to develop single-page applications. 

Javascript is a scripting language that runs on the client-side. Scripts are embedded in the document, and they interact with DOM. At present, almost all web browsers have an inbuilt javascript engine responsible for running the script at the client-side.

Javascript can reload the webpage by refreshing it. Javascript supports strong animations, including zooming in on objects, making objects move on the web page, and letting users resize the web page. Javascript can develop games that can run on web browsers. Javascript can control streaming media and develop ads that can pop up on the web browser on user action. Javascript also supports client-side validation of user input before forwarding the user input to the web browser. With the help of javascript, users can be redirected to the desired web page.

Javascript supports third-party frameworks that are extensively used to develop web-based applications. jQuery is one of the third-party javascript libraries used to develop interactive web-based applications. React is another javascript library that was developed by Facebook. React is open source and is extensively used by Twitter. Angular is another third-party framework used by YouTube and Gmail. Angular is an open-source javascript library.

Javascript is now also being used in server-side applications and browser-less applications. Node.js is a javascript framework used to develop server-side applications using javascript. React Native is also a framework that is implemented in Javascript. Applications such as Adobe Acrobat also support Javascript-based PDF documents. Node.js is used for applications of embedded systems.

Programs in javascript are structured and support if statements, switch statements, while loops and do-while loops etc.,. Moreover, Javascript can make a difference between expression and statements. 

Typecasting in javascript is weak. Typecasting is automatic in javascript, depending on the type of operation done. For example, + operator can be used to concatenate strings as well as add numbers. Its functionality is decided by the type of operands on which ‘+’ operator is applied. ‘+’ operator considers its operands to be a number, in the same way ‘-’ operator considers both of its operands to be a number. Thus, both ‘+’ and ‘-’ operator considers its operands to be a number and perform operations accordingly.

Javascript supports dynamic typecasting, as is the case with other scripting languages. In javascript, a variable declared to hold a numeric value can also hold a string value. Javascript has the functionality to check the type of an object, to check the type of a particular object, duck typing is used.

Javascript functions such as eval can evaluate strings when the web page is loaded in the client browser. Moreover, in Javascript, objects can be used to call variables of a class using dot operator or member access operator, for example, object. x. Javascript also supports for..in the loop.

In Javascript, classes can be created and also be inherited from the already existing classes. Javascript supports in-built constructors such as Array or Object. These in-built constructors can also be modified. Javascript runs on a web browser to interact with the user. These web-browsers are often single-threaded. Javascript maintains function calls, maintains variable states and their values using stack.

Functions in Javascript support parameters that are passed to function definition when they are called. Thus functions in Javascript have the ability to manipulate formal parameters. Javascript supports the functionality of holding values and providing them later when required. 

Below is the Javascript example that moves the image to the right when the user presses the button.

Javascript Program Example

      <title>JavaScript Example for Animation</title>
      <script type = "text/javascript">
            var img_Obj = null;
            function init() 
               img_Obj = document.getElementById('my_Img');
               img_Obj.style.position= 'relative'; 
               img_Obj.style.left = '0px';
            function move_Right() 
               img_Obj.style.left = parseInt(img_Obj.style.left) + 10 + 'px';
            window.onload = init;
         <img id = "my_Img" src = "/images/html.gif"/>
         <p>Please Click below gievn button, this button will move the image to the right side</p>
         <input type = "button" value = "Click Me Please" onclick = "move_Right();" />

Javascript can create scripts that can do web-based actions and can not perform manipulation tasks.

Lightweight programming language has the following features:

  • Lightweight programming languages use minimum hardware resources and minimum software resources.
  • Memory requirement of a lightweight programming language is less.
  • The program size of a lightweight programming language is less.

Javascript is a programming language that can work on minimum hardware resources and minimum software resources. To compile and produce an output of a Javascript program requires much less memory. Javascript is a platform-independent language and programs developed using javascript are portable.

Javascript does not require intensive CPU resources and the output of the program can be produced using the least RAM. Javascript can have a complex framework but even then it can be executed on the browser.

Most of the processing of Javascript programs is carried out at client instead of server-side; this is also one of the reasons to say that javascript is a lightweight programming language. 

Javascript is also considered a lightweight programming language since the syntax and semantics of the language is easy and simple.