In this paper, starting from vivo Internet technology WeChat public links: mp.weixin.qq.com/s/fPNMaeNYg… Author: Kong Chuiliang
【 Front-end science Popularization Series 】 Past highlights:
“Front-end Science Series (1) : A Brief History of the Front-end” mainly introduces the history and big events of the development of the Web front-end.
This is a series of articles (2), mainly introduces the past life of Node.js, core technology and the story behind it.
About Node.js
1. The Node. Js is what
Node.js® is a JavaScript runtime built on Chrome’s V8 JavaScript engine.
According to the node.js website, the explanation is very simple:
Node.js® is a JavaScript runtime based on the Chrome V8 engine.
So what should we make of this sentence?
-
Node.js is not a JavaScript application, a framework, or a language. It’s a JavaScript runtime environment, just like a browser is a JavaScript runtime environment.
-
It is built on top of Chrome’s famous JavaScript engine, V8.
We have to talk about Chrome & V8.
2. Background of the birth of Node.js
Google launched Google Maps in 2008, but Google Maps was native to Android at the time. To further expand the scope of Google Maps, Google has developed a browser version of Google Maps for browsers. This put a higher demand on the processing power of the browser, so Sundar Pichai, the product manager at the time, persuaded the board to develop a browser (now Chrome).
At the time, the browser market was still Owned by Microsoft, because Internet Explorer was built into the operating system, making it almost dominant, and Internet Explorer was free, so the board was very opposed to developing a browser.
Sundar Pichai emphasizes that the value is not in the browser itself, but in what it can access: web applications. The most profitable products at the time, like Google Docs. He eventually convinced the board that Google Maps needed to radically improve the browser’s performance if it was to attract more users and make money from advertising sales.
Then there is the question of how to improve browser performance. The team realized that developers were reluctant to use JavaScript because it ran too slowly in browsers, not on the same scale as traditional languages.
Just then Lars Bak appeared. The genius behind Google Chrome first caught silicon Valley’s attention back in 1991 and went on to become one of the industry’s best programmers. In early 2000, however, he chose to leave Silicon Valley and return to his native Denmark to live happily ever after. He felt that silicon Valley developers worked too hard and led an unhealthy lifestyle. When Lars Bak returned to Denmark and earned enough money to support his family, he rented a large farm and began painting farmhouses.
Then I got a call from Sundar Pichai. Lars Bak says he didn’t care about being a senior manager. All he wanted to do was push the boundaries of technology. He accepted an offer from Google, but instead of returning to Silicon Valley, he started working on his own farm.
V8 became open source on September 2, 2008, the same day as Chrome. The world discovered Chrome in an unusual way. Chrome was introduced via Google’s earlier comic book release. Pr reacted to the news with a flurry of conference calls, blog posts explaining what was going on, a press conference and, finally, a product demonstration at the Googleplex.
Those of you who watched the press conference may have noticed that it was very hurried and there was not even a nice PPT.
(Photo from Internet)
The possibility of embedding V8 in non-browser projects is explicitly mentioned in the comics.
3. The Node. The birth of js
When talking about the birth of Node.js, it is inevitable to talk about its creator, Ryan Dahl. Ryan Dahl was an expert in the development of high-performance Web services before he developed Node.js. While helping customers solve performance problems, he encountered performance problems caused by high concurrency of Web services. He tried many languages but failed. After years of research, Ryan Dahl had a general feeling that the key to solving problems was event-driven and asynchronous I/O.
He was on the verge of despair when V8 came along with Chrome, and the efficiency of the JavaScript language improved substantially. This gave Ryan Dahl a new revelation: JavaScript is inherently single-threaded, and browser-initiated AJAX requests are non-blocking. If you combine JavaScript with asynchronous IO and a simple HTTP server, it becomes a cool thing. That’s how his original research collided with V8, which fulfilled all of his fantasies about high-performance Web services:
-
No history baggage, no synchronous I/O. There is no case where a synchronous I/O causes event loop performance to degrade dramatically.
-
V8 is good enough, far faster than other scripting languages like Python and Ruby.
-
The closure feature of the JavaScript language is very convenient and works better than the callbacks in C.
In February 2009, he submitted the first line of code for the project, which was eventually named “Node”.
Ryan Dahl officially announced his project in May 2009.
Node.js became popular after Ryan Dahl gave a talk about it at the JSConf EU conference in Berlin in late 2009.
In general, Node.js didn’t happen out of thin air. It came about thanks to years of research by Ryan Dahl and just the right Node.
2. Current status of Node.js
On May 31, 2018, the Node.js Foundation released a user survey showing that learning Node.js seems to be getting easier, with 43% of users with less than 2 years of Node experience saying it’s “easy.” The vast majority (85%) of Node.js users are used for web development, 43% are involved in some enterprise development, 13% are used for big data analytics, and 8% are used for embedded systems.
The user survey also revealed that users surveyed used the following terms to describe Node.js.
(Photo from Internet)
More importantly, the report shows that the Node.js community is still growing rapidly. This is helped by the fact that Node.js can be used in a wide variety of scenarios.
More and more developers are turning to Node.js, and almost every company/group has its own command-line tools, scaffolding. Node.js allows you to quickly develop a variety of artifacts that can greatly improve development efficiency.
3. Core technology of Node.js
Node.js is event-driven, asynchronous programming and designed for web services.
Earlier when we talked about the birth of Node.js, we mentioned that Ryan Dahl, the creator of Node.js, designed Node.js to solve the performance problem caused by high concurrency of Web services, and this problem was solved with the introduction of V8.
As shown below, when a network request occurs, node.js registers a callback function if there is a file or database operation and proceeds to the next request. When the previous file or database operation is complete, the previously registered event callback is triggered to respond to the previous network request.
Because the whole design is event-driven, it has the important advantage of making full use of system resources, executing code without blocking and waiting for certain operations to complete, and the limited resources can be used for other tasks.
Ryan Dahl went around for a long time trying to convince people that blocking IO was the wrong way to do it, and that if you did everything in a non-blocking way, you could solve a lot of the difficulties.
For more information on event-driven programming, please refer to my article “JavaScript Runtime mechanism: Event-driven Programming in Detail”.
Node.js performs well.
According to the user survey report mentioned earlier, node.js is rated by users as Fast, right, Fast!
According to Ryan Dahl, performance is an important consideration in node.js, and the choice of C++ and V8 over others is based on performance.
Node.js is bold in design. It runs in single-process and single-thread mode (consistent with the running mode of Javascript). The event-driven mechanism is realized by maintaining the event cycle queue efficiently through the internal single thread of Node.JS. This means that in the face of large HTTP requests, Node.js is event-driven and takes care of everything. From this we can see that this design causes the load to be concentrated on the CPU rather than the memory. So Node.js is particularly suited for IO-intensive applications, where the CPU can be harnessed to its full potential.
Node.js supports JavaScript.
This is a very important indirect reason why Node.js has grown.
-
First, Javascript, as the primary language for front-end engineers, has considerable appeal in the technical community. Moreover, with the continuous development of Web technology, especially the increasing importance of the front end, many front-end engineers began to try the water of “background application”. In many enterprises that use Node.js, engineers say that because they are used to Javascript, they choose Node.js.
-
Second, Javascript’s anonymous functions and closure features lend themselves well to event-driven, asynchronous programming.
-
Node.js also benefits from the Google V8 engine.
Of course, event-driven and asynchronous programming is not without its drawbacks. When all callback functions are written, it will go against normal people’s thinking. At first, it will be especially difficult to get used to, and too many callback will easily lead to callback hell.
4. The people behind Node.js
When Node.js was born, it attracted a bunch of interesting people to the early development of Node.js. From the beginning, they realized that package management would be very useful in Node.js, so they started developing package management tools. One of them was Isaac Schlueter, a Yahoo employee who was obsessed with Node.js and quit his job to focus on developing a package management tool (now CALLED NPM). He had been heavily involved in Nodejs development, This allows him to implement CommonJS module specifications in Node.js.
The package management tool was good enough to get Node official support, and it won. The package management tool, or NPM, is starting to come bundled with the Node installation package, rather than being a separate third-party plug-in that doesn’t require you to download the package management tool after installing Node. This Node official certification of the gold signboard has been hanging up to today.
It was around this time (2010, the year after Node.js was born) that a Silicon Valley-based startup noticed the project. Joyent specializes in cloud computing and data analytics. Joyent realized the value of the Node.js project and bought It from Ryan Dahl for a fraction of the price.
Ryan Dahl sold all of Node.js, including the source code, to Joyent for just a few tens of thousands of dollars. Millions of people use Node.js as a JavaScript development tool every day, and the people who invented Node.js make tens of thousands of dollars from it.
Ryan Dahl then joined Joyent as a full-time developer of Node.js, and it was at this point that Node.js entered the second phase of its life: moving from a personal project to a corporate project. Joyent has registered the “Node.js” trademark and requires legal authorization to use its content.
NPM author Isaac Schlueter, meanwhile, was hired by Joyent to develop Node.js, but retains ownership of the nPMjs.org domain name, the NPM source code, and any patents in it, all of which are his own intellectual property. This decision will have far-reaching consequences for generations to come…
Ryan Dahl became an even bigger figure after joining Joyent as a full-time Node developer. Attend conferences, be asked by fans to take photos, write anything will get a lot of response. Ryan doesn’t like it. “I’m a programmer,” he says. “I want to write code, and I want to express my ideas freely. I don’t like it…” .
Ryan Dahl left Node.js in 2012 just as it was in its heyday. Isaac Schlueter, author of NPM, replaced him as the project leader. This is when JavaScript developers come in and implement a tool in JavaScript that will never look at another language! So they started developing Node programs in Javascript and enjoyed it.
Isaac Schlueter saw how cheap Joyent paid Ryan Dahl and knew how much Node.js should be worth. In 2013, he decided to go commercial with NPM, so he handed in his resignation to Joyent and started a company called NPM. From this point on, Node.js began to have serious problems: the frequency of contributions began to decline, code submissions came mainly from the community, the version of the code dropped to three months before a small version was released, and the 1.0 release that the community had been waiting for was delayed. In addition, there were personal pronouns that made node.js project less active, Joyent’s inaction on the project and other levels’ intervention on other members of the community, which made the project progress very slow. The snail’s pace is not an overstatement.
In August 2014, several key contributors, led by Mikeal Rogers, a respected member of the community, launched the IO. Js project, announcing the official split of the Node.js community. IO. Js is no longer a technical director mode, but a technical committee mode. IO. Js was released as v1.0.0 on January 14, 2015. Since then, IO. Js has gone from bad to bad, releasing new versions every week, keeping node.js architectically (as established by Ryan Dahl) but embracing ECMAScript 6, reverting to weekly updates.
At the same time, Joyent recognized the problem and set up a temporary Node.js advisory board to create a more open management model, to find a way to balance the needs of all members and provide a platform for all parties to invest resources into node.js. The advisory board investigated IBM (Eclipse), Linux Foundation, Apache, etc., and decided on the form of the Node.js Foundation.
In May 2015, the Node.js advisory board finally decided to settle with IO. Js and work together on a new management model to ensure node.js’s future development. Joyent also made a big concession on this issue in the spirit of openness. But by this time, io.js had already released version 2.0, and Node.js was far behind IO. The final solution was that both Node.js projects and IO. Future releases of Node.js will be based on the current progress of IO. Js, meaning that IO. Js will continue to be released, and the next major release of Node.js will move from 1.0, 2.0, 3.0 to 4.0. As shown below:
Then NPM got bigger and stronger, making Node.js’s popularity explode. All JavaScript developers have started developing in Node.js, and NPM has become an integral part of every JavaScript developer’s daily routine. Few people know that NPM is a business, a private company funded by venture capital.
What does it mean to have one company at the helm of NPM’s business strategy? At last year’s conference, Ryan Dahl, the creator of Node.js, spoke again. He talked about node.js design pitfalls. It said:
The centralization (or even private control) of the module repository is unfortunate. – Ryan Dahl
At the beginning of 2016, “Xue Case triggered by an 11-line module” occurred in NPM circle. The left-pad tool module was removed from NPM by the author, and all NPM packages that relied directly or indirectly on it sadly died, including popular projects like Babel.
And here’s why: The author Azer wrote a tool named Kik with the same name as a certain company. One day, the company’s lawyer asked him to delete this module and “surrender” the name kik to them. The author refused, so the lawyer went directly to NPM, and NPM transferred the package permission to this company without the author’s consent. So Azer went ballistic and deleted all of his NPM packages.
Next, Commonjs and the front-end modular specification…
reference
-
How to learn Node.js correctly
-
Lars Bak: The genius behind Google’s Chrome browser
-
Node.js and io.js
-
Node.js: What is Node.js
-
NPM’s Economic Landscape (PART 1)
-
What can we learn from the Left-pad incident
-
Ryan Dahl, Father of Node: I don’t want to be defined
-
The 2018 Node.js user survey reports that the community is still growing fast
For more content, please pay attention to vivo Internet technology wechat public account
Note: To reprint the article, please contact our wechat account: LABs2020.