Home >Web Front-end >JS Tutorial >What does nodejs do?

What does nodejs do?

藏色散人
藏色散人Original
2021-09-01 11:52:1626293browse

nodejs is an open source, cross-platform running environment that can run JavaScript on the server side; Node.js uses the V8 running code developed by Google and uses technologies such as event-driven, non-blocking and asynchronous input and output models to improve Performance, optimizing application transfer volume and scale.

What does nodejs do?

The operating environment of this article: Windows 7 system, nodejs version 10.16.2, DELL G3 computer.

What does nodejs do?

Node.js is an open source, cross-platform operating environment that can run JavaScript on the server side. Node.js is owned and maintained by the OpenJS Foundation (formerly the Node.js Foundation, which merged with the JS Foundation) and is a project of the Linux Foundation. Node.js uses the V8 running code developed by Google and uses technologies such as event-driven, non-blocking and asynchronous input and output models to improve performance and optimize the transmission volume and scale of applications. These techniques are typically used in data-intensive real-time applications.

Node.js Most of the basic modules are written in JavaScript language. Before the emergence of Node.js, JavaScript was usually used as a client-side programming language, and programs written in JavaScript often ran on the user's browser. The emergence of Node.js enables JavaScript to be used for server-side programming. Node.js contains a series of built-in modules that allow the program to run as a standalone server without Apache HTTP Server or IIS.

nodejs introduction:

Node.js is a very hot technology at present, but its birth experience is very strange.

As we all know, in just a few months after Netscape designed JavaScript, JavaScript was actually the only standard for front-end development.

Later, Microsoft defeated Netscape through IE and unified the desktop. As a result, the browser made no progress in a few years. (The ancient IE 6 launched in 2001 is still used by people today!)

There will be no development without competition. Microsoft believed that the IE6 browser was already very complete and had almost no room for improvement, so it disbanded the IE6 development team! However, Google believes that the new generation of browsers that support modern web applications has just begun, especially the performance of the browser's engine responsible for running JavaScript can be improved by 10 times.

First, Mozilla launched the Firefox browser in 2002 with the help of the legacy of Netscape, which had sacrificed its life. Then in 2003, Apple launched the Safari browser with WebKit core based on the open source KHTML browser, but only Limited to Mac platform.

Subsequently, Google also began to create its own browser. They also took a fancy to the WebKit core, so they launched the Chrome browser based on the WebKit core.

The Chrome browser works across Windows and Mac platforms, and Google believes that to run modern web applications, the browser must have a very powerful JavaScript engine, so Google developed a high-performance JavaScript engine. The name is V8, and it is open source under the BSD license.

The modern browser war has left Microsoft's IE browser far behind because they disbanded the most experienced and most powerful browser team! Looking back and catching up, I found that WebKit supporting HTML5 has become a standard on mobile phones, and IE browser has since been isolated from mainstream mobile devices.

What does the browser war have to do with Node?

There is a guy named Ryan Dahl. His job is to write high-performance web services using C/C. For high performance, asynchronous IO and event-driven are the basic principles, but writing in C/C is too painful. So this friend began to imagine using high-level languages ​​to develop Web services. He evaluated many high-level languages ​​and found that although many languages ​​​​provide both synchronous IO and asynchronous IO, once developers use synchronous IO, they are no longer too lazy to write asynchronous IO, so in the end, Ryan aimed at JavaScript.

Because JavaScript is executed in a single thread and cannot perform synchronous IO operations at all, this "defect" of JavaScript causes it to only use asynchronous IO.

The development language is selected, and a runtime engine is also required. This guy once considered writing one himself, but wisely gave up because V8 is an open source JavaScript engine. Let Google invest in optimizing V8, and we will only modify it for use without having to pay. This is a very cost-effective deal.

So in 2009, Ryan officially launched an open source web server project based on JavaScript language and V8 engine, named Node.js. Although the name is very tacky, Node brought JavaScript to back-end server development for the first time, and there were already countless JavaScript developers in the world, so Node became popular all of a sudden.

What are the advantages of JavaScript running on Node compared to other back-end development languages?

The biggest advantage is that with the help of JavaScript's natural event-driven mechanism and V8 high-performance engine, it is easy to write high-performance Web services.

Secondly, the JavaScript language itself is a complete functional language. During front-end development, developers often write more casually, making people feel that JavaScript is a "toy language". However, in the Node environment, through modular JavaScript code, functional programming, and without considering browser compatibility issues, the latest ECMAScript 6 standard can be directly used to fully meet engineering needs.

I have also heard of io.js, what the hell is this?

Because Node.js is an open source project, although it is driven by the community, it has always been funded by Joyent behind the scenes. Because a group of developers were dissatisfied with Joyent's strategy, they forked the io.js project from the Node.js project in 2014 and decided to develop it separately, but the two are actually compatible.

However, there is an old saying in China, which is called "If we divide for a long time, we must unite; if we unite for a long time, we must divide." Not long after the separation, Joyent said it wanted to reconcile, so the io.js project decided to return to Node.js.

The specific approach is that in the future, io.js will first add new features. If everyone is happy with the test, the new features will be added to Node.js. io.js is the "early adopter version", while Node.js is the online stable version, which is equivalent to the relationship between Fedora Linux and RHEL.

Recommended learning: "nodejs video tutorial"

The above is the detailed content of What does nodejs do?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn