• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer
  • Home
  • Java Tutorial
  • Java Posts
  • Node.js
  • Spring Core
  • Algorithms
  • Docker
  • Blogging
  • Misc
Tech Stack Journal

Tech Stack Journal

Introduction to Node.js

Contents

  • 1 What is Node.js and Why it is used?
  • 2 3 Building Blocks of Node.js
  • 3 What is V8 JavaScript Engine?
  • 4 What is JavaScript Run-time?
  • 5 Is Node.js used for frontend or backend?
  • 6 Is Node.js easier than Java?
  • 7 Getting Started with Node.js
  • 8 References

What is Node.js and Why it is used?

Node.js is an asynchronous event-driven JavaScript run-time built on Chrome’s V8 JavaScript engine.

Node.js is famous for the non-blocking, asynchronous and network programming. Node.js is a popular choice to create web server these days for the responsive UI websites.

“Node. js” is also called as a server-side “JavaScript” platform. Its creator Ryan Dahl introduced it during 2009 JSConf.eu Conference. Contributions from the community resulted in evolution of Node.js. Also, its sponsor cloud computing company Joyent contributed for its successful growth.

3 Building Blocks of Node.js

“Node” is comprised of three building blocks.

  1. A cross-platform and event-driven IO library called as “Lib UV” which was actually built to port Node.js to Windows environment. It replace many Unix specific libraries so that it is compatible with Window environment.
  2. The “JavaScript” engine developed by Google called as “V8” for its Chrome web browser. All of the Node.js releases made sure that it is within the realm of Google’s updated “V8” by leveraging Google’s innovations to V8.
  3. Customized C++ and JavaScript code specific to Node.js

What is V8 JavaScript Engine?

  • V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
  • It is used in Chrome and in Node.js. V8 compiles and executes JavaScript source code, handles memory allocation for objects, and garbage collects objects it no longer needs.
  • When you run a program, V8 engine compiles the JavaScript code using Just in-time (JIT) compilation to make it understandable for OS.

What is JavaScript Run-time?

  • A JavaScript run-time is a platform where JavaScript programs can be executed.
  • Node.js is an example of JavaScript run-time where you can run JavaScript code on Node.js without requiring the browser.

Is Node.js used for frontend or backend?

The short answer is, it is used for frontend, backend and standalone programs as well. Node.js is based on JavaScript’s V8 engine, but it doesn’t mean that it is only for frontend programming. Node.js effectively uses the V8’s single thread processing, which makes it very lightweight network programming language. What it basically does is that it delegates blocking operations to the host operating system, which is the reason why it performs well even being single threaded programming language.

Is Node.js easier than Java?

Since Node.js adapts JavaScript’s ECMAScript syntax, if you know JavaScript, it is easier for you to learn. In fact, if you know JavaScript you can focus on the Node.js specific concepts. But, is it easier than Java? If you know JavaScript is inspired from Java syntax, so most of the Java syntax is similar to what you learn in Node.js. However, there are differences in terms of how we implement some fundamental concepts like non-blocking programming, Promises etc.,

Getting Started with Node.js

You can get Node.js in various ways. You can download the installers from nodejs.org and install using its wizard which takes care of installation and configuring the environment variables etc., or else, you can directly download the binaries also, and configure the environment variables etc., correctly. If you would like to build it on yourself, then you can also download the source code from its repository.

You can also make use of a tool called “NVM” developed by Tim Caswell. Using nvm you can clone different versions of Node.js from its GitHub. You can use nvm to install and manage multiple Node.js versions. It is extremely helpful as it allows us to test our code with multiple Node versions.

Once you clone nvm, we can use “nvm install” and specifying the version number to install specific Node version. After installation, you can switch between different Node versions using “nvm use” command. You can also set 1 particular version as the default one by using the command “nvm alias default”.

References

  • V8 Docs
  • Node.js Documentation

Primary Sidebar

More to See

Arrays.asList in Java Examples

February 21, 2021 By Admin

[Solved] Why List.add throws UnsupportedOperationException in Java?

February 20, 2021 By Admin

Secondary Sidebar

  • Node.js Tutorial
    • Introduction to Node.js
    • Modules
    • package.json
    • Blocking and Non-Blocking Code
    • Events using EventEmitter
    • Streams – Readable Stream, Writable Stream, Duplex Stream and Transform Stream

Categories

  • Algorithms
  • Blogging
  • Docker
  • Java
  • Misc
  • Node.js
  • Spring Core
  • Windows

Archives

  • February 2021 (6)
  • January 2021 (1)
  • December 2020 (1)
  • September 2020 (2)
  • August 2020 (5)
  • July 2020 (4)
  • June 2020 (1)
  • May 2020 (4)
  • April 2020 (22)
  • November 2019 (3)
  • September 2019 (2)
  • August 2019 (6)

Footer

Navigation

  • Home
  • Java Tutorial
  • Java Posts
  • Node.js
  • Spring Core
  • Algorithms
  • Docker
  • Blogging
  • Misc

Recent

  • How to Make File Explorer Open to This PC instead of Quick Access in Windows 10
  • Arrays.asList in Java Examples
  • [Solved] Why List.add throws UnsupportedOperationException in Java?
  • How to Convert an Array to List in Java?
  • How Many Spaces in a Tab?

Search

Copyright © 2021 · Tech Stack Journal · Log in