In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces you how to carry out Node.js analysis, the content is very detailed, interested friends can refer to, hope to be helpful to you.
What is Node.js1.Node.js
Node.js ®is a JavaScript runtime built on Chrome's V8 JavaScript engine.
According to the explanation on the Node.js website, it is very simple:
Node.js ®is a JavaScript runtime based on the Chrome V8 engine.
So how do we understand this sentence?
Node.js is not an application of JavaScript, nor a framework, let alone a language. It is a JavaScript runtime environment, just as a browser is a JavaScript runtime environment.
It is built on Chrome's V8, the famous JavaScript engine.
We have to talk about Chrome & V8 here.
The background of 2.Node.js 's birth
Google developed Google Maps in 2008, but Google Maps was then a native app for Android. In order to further expand the scope of Google Maps services, Google has developed a browser version of Google Maps for browsers. This put forward higher requirements for the processing power of browsers, so Sundar Pichai, the product manager at that time, tried to persuade the board of directors at that time to develop a browser (now Chrome).
At that time, the browser market was still Microsoft, because the operating system built-in IE, so that IE almost occupied the whole country, and IE was free, so at that time to develop a browser was strongly opposed by the board of directors.
Sundar Pichai emphasizes that the value lies not in the browser itself, but in what it can access: that is, web applications. The most expensive products at that time, such as Google documents. If Google Maps is to attract more users and profit from advertising sales, it must thoroughly improve the performance of the browser, and in the end, he persuaded the board to set up the development browser.
Then comes the question of how to improve browser performance. At that time, the project team realized that developers were reluctant to use JavaScript because it ran too slowly in browsers and was not of the same order of magnitude as traditional languages.
Just then, Lars Bak appeared. The genius behind Google Chrome attracted attention in Silicon Valley as early as 1991 and later became one of the best programmers in the industry. But in early 2000, he chose to leave Silicon Valley and return to his native Denmark to live a happy life. He felt that the developers in Silicon Valley worked too hard and had an unhealthy lifestyle. When Lars Bak returned to Denmark and earned enough money to support his family, he rented a large farm and began to paint the farmhouse.
And then I got a call from Sundar Pichai. Lars Bak said he didn't care about being a senior manager, and all he wanted to do was to break the boundaries of technology, so he accepted Google's offer, but instead of returning to Silicon Valley, he started working on his own farm.
On September 2, 2008, V8 and Chrome announced open source on the same day. The world discovered Chrome in an extraordinary way. Chrome was distributed through comic books released earlier by Google. The publicist responded to the news in a hurry, held a conference call, posted a blog post to explain what was going on, and then decided to hold a press conference and finally hold a product presentation at Googleplex.
Students who have seen the press conference may have noticed that they were in such a hurry that they did not even have a beautiful PPT.
(the picture comes from the Internet)
The cartoon explicitly mentions the possibility of embedding V8 in non-browser projects.
The birth of 3.Node.js
When it comes to the birth of Node.js, it is inevitable to talk about its founder, Ryan Dahl, the father of Node.js. Ryan Dahl was an expert in the development of high-performance Web services before developing Node.js. While helping customers solve performance problems, he encountered performance problems caused by the high concurrency of Web services. He tried many languages and failed. After years of research, Ryan Dahl roughly feels that the key to solving the problem is to achieve the goal through event-driven and asynchronous Imando O.
Just when he was on the verge of despair, V8 appeared with the advent of Chrome browser, and the execution efficiency of JavaScript scripting language was improved qualitatively, which brought new enlightenment to Ryan Dahl: JavaScript itself is single-threaded, and AJAX requests made by browsers are non-blocking. If you combine JavaScript with asynchronous IO and a simple HTTP server, it becomes a cool thing. This is how his original research collided with V8, which meets all his fantasies about high-performance Web services:
There is no historical baggage, no synchronized Igamo. There will not be a situation in which the performance of the event loop degrades sharply as a result of a synchronous Istroke O.
V8 performs well enough to be much faster than engines in other scripting languages such as Python and Ruby.
The closure feature of the JavaScript language is very convenient and easier to use than the callback function in C.
So in February 2009, with a new idea, he submitted the first line of code for the project, which was eventually named "node".
In May 2009, Ryan Dahl officially announced his project.
At the end of 2009, Ryan Dahl delivered a speech on Node.js at the JSConf EU conference in Berlin, and Node.js became more and more popular around the world.
All in all, Node.js is not born out of thin air, it is due to years of research by Ryan Dahl and a just right node.
II. Current situation of Node.js
A user survey released by the Node.js Foundation on May 31, 2018 showed that it seemed easier to learn Node.js, with 43% of users with less than 2 years of node experience finding it "easy". The vast majority (85%) of Node.js users are used for web development, 43% for enterprise-level development, 13% for big data analysis and 8% for embedded systems.
The user survey report also shows that the users interviewed will use the following words to describe Node.js.
(the picture comes from the Internet)
More importantly, the report shows that the Node.js community is still growing rapidly. This is due to the wide range of application scenarios of Node.js.
More and more developers are turning to Node.js, and almost every company / group has its own command-line tools and scaffolding. Using Node.js, you can quickly develop a variety of artifacts that can greatly improve the efficiency of development.
III. Node.js Core Science and Technology
Node.js adopts event-driven and asynchronous programming, and is designed for network services.
When we talked about the birth of Node.js, we mentioned that Ryan Dahl, the father of Node.js, designed Node.js to solve the performance problem caused by high concurrency of web services, and this problem was easily solved with the advent of V8.
As shown in the following figure, when a network request occurs, if there is a file or database operation, Node.js will register a callback function and then process the next request. When the previous file or database operation is completed, the previously registered event callback is triggered to respond to the previous network request.
Because the whole design is event-driven as the core, its important advantage is that it makes full use of system resources, executes code without blocking and waits for some operation to be completed, and limited resources can be used for other tasks.
For a long time after that, Ryan Dahl gave speeches everywhere, trying to convince people that blocking IO was the wrong way, and that many difficulties could be solved if you handled everything in a non-blocking way.
About event-driven programming, you can refer to my article Zhihu: "JavaScript operating Mechanism: a detailed explanation of event-driven programming"
The performance of Node.js is good.
The above-mentioned user survey report shows that the most user evaluation of Node.js is Fast, yes, it is fast!
According to Ryan Dahl, performance is an important consideration for Node.js, and choosing C++ and V8 over nothing else is also based on performance considerations.
Node.js is bold in design, it runs in single-process and single-thread mode (consistent with Javascript), event-driven mechanism is realized by Node.js through internal single-thread efficient maintenance of event loop queue, there is no multi-threaded resource consumption and context switching, which means that in the face of large-scale http requests, Node.js relies on event-driven to do everything. From this we can know that such a design will cause the pressure of the load to be concentrated on CPU rather than memory. Therefore, Node.js is especially suitable for IO-intensive applications, which can give full play to the power of CPU.
Node.js supports JavaScript.
This is a very important indirect reason why Node.js can grow and grow.
First of all, as the main language of front-end engineers, Javascript has considerable appeal in the technical community. Moreover, with the continuous development of Web technology, especially the increasing importance of front-end, many front-end engineers began to try out "background applications". In many enterprises that adopted Node.js, engineers said that they chose Node.js because they were used to Javascript.
Second, Javascript's anonymous functions and closures are well suited for event-driven and asynchronous programming.
With the support of the Google V8 engine, the performance of Node.js also benefits.
Of course, event-driven and asynchronous programming is not without its disadvantages. When it is written as a callback function, it will violate the thinking of normal people, and it will be very unaccustomed at first, and too many callbacks will easily lead to callback hell. Of course, Promise, Async and Await are all committed to solving this problem.
Fourth, the people behind Node.js, those things.
After the birth of Node.js, it attracted a group of interesting people to participate in the early development of Node.js. From the beginning, they found that package management would have a great opportunity to use their talents in Node.js, so they began to develop their own package management tools. One of them, Isaac Schlueter, an Yahoo employee obsessed with Node.js, quit his job and began to focus on the development package management tools (now npm). He was deeply involved in the development of Nodejs, which enabled him to implement the module specification of CommonJS in Node.js.
This package management tool is good enough to have strong support from Node officials, and it won. This package management tool, or npm, begins to be bundled with the Node installation package. It is not a separate third-party plug-in and does not require you to download the package management tool after installing Node. This gold-lettered signboard officially certified by Node has been hung to this day.
It was at this time (2010, the second year of Node.js 's birth) that a Silicon Valley startup noticed the project. The company is Joyent, which is mainly engaged in cloud computing and data analysis. Joyent realized the value of the Node.js project, and Joyent bought Node.js from Ryan Dahl for a small sum of money.
Ryan Dahl sold all the shares of Node.js, including source code, to Joyent for only tens of thousands of dollars. Millions of people use Node.js as a tool for JavaScript development every day, while the people who invented Node.js made only tens of thousands of dollars with it.
After that, Ryan Dahl joined Joyent and was full-time responsible for the development of Node.js, and from this moment on, Node.js entered the second phase of its life: from a personal project to a project organized by a company. Joyent has registered the trademark "Node.js", and the use of its related content requires legal authorization.
Meanwhile, Isaac Schlueter, the author of npm, was hired by Joyent to develop Node.js, but he retained ownership of the npmjs.org domain name, npm source code, and any patents in the source code, which are his own intellectual property rights. This decision will have a far-reaching impact on future generations.
After joining Joyent to become a full-time Node developer, Ryan Dahl also became a more important person. Attend various conferences, be asked by fans to take photos, write something casually, there will be a lot of people respond. But Ryan does not like this state, he said: "I am a programmer, I want to write code, I want to express my ideas freely. I don't like this state." .
In 2012, when Node.js was in its heyday, Ryan Dahl chose to leave Node.js. Isaac Schlueter, the author of npm, succeeded him as the leader of the project team. It was at this time that JavaScript developers appeared on the scene and could implement a tool in JavaScript, and they would never take a look at other languages! So they started developing Node programs in Javascript and enjoyed it.
Isaac Schlueter has seen first-hand how cheap Joyent is paying Ryan Dahl and knows how much Node.js should be worth. So in 2013, he decided to commercialize npm, so he tendered his resignation to Joyent and set up a company, npm. From then on, Node.js had a serious problem: the frequency of contribution began to decline, the code submission mainly came from the community, the version of the code was reduced to three months to release a small version, and the version 1.0 that the community had been waiting for could not be released for a long time. In addition, personal pronoun events have led to a lower activity of the Node.js project. Joyent's inaction on the project and other levels of intervention on other members of the community have led to the slow progress of the project, which is not too fast to describe as a snail.
In August 2014, led by the prestigious Mikeal Rogers in the community, several important core contributors launched the io.js project, announcing the formal division of the Node.js community. Io.js is no longer the technical leader model, but is replaced by the technical committee model. Io.js released v1.0.0 on 2015-01-14. Since then, io.js has been out of control, releasing new versions on a weekly basis, still looking like Node.js at the architectural level (established by Ryan Dahl) but embracing ECMAScript 6 and re-maintaining the weekly update frequency.
At the same time, Joyent is aware of the problem and set up an interim Node.js Advisory Committee to create a more open management model in the form of an advisory committee, in order to find a way to balance the needs of all members and provide a platform for all parties to invest resources into Node.js projects. The Advisory Committee investigated IBM (Eclipse), Linux Foundation, Apache, etc., and decided to establish the form of Node.js Foundation.
In May 2015, the Node.js Advisory Committee finally decided to reconcile with io.js to develop a new management model to ensure the next development of Node.js. Joyent also made great concessions in this matter in line with the principle of openness. But at this time, io.js has released version 2.0, and Node.js lags far behind io.js. The final solution is that both the Node.js project and the io.js project will join the Node.js Foundation. After the Node.js Foundation, the release of the Node.js version will be based on the current progress of io.js, that is, io.js will continue to be released, while the next major version of Node.js will go beyond 1.0,2.0,3.0. Go straight to 4.0. As shown in the following figure:
Then, npm also became bigger and stronger, making the penetration rate of Node.js explosive. All JavaScript developers start to use Node.js for development, and npm has become an integral part of every JavaScript developer's daily work. But few people know that npm is a company, a private company sponsored by venture capital.
What is the meaning of npm's business strategy that a company is at the helm? At this conference last year, Ryan Dahl, the father of Node.js, took the stage again. He talked about the design misunderstanding of Node.js. There is a sentence in it:
The centralization of module repositories (even privately controlled) is unfortunate. -- Ryan Dahl
This is the end of the analysis on how to carry out Node.js. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 275
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.