I. recognize node. js
(i) Birth
Founded in 2008 by Ryan Dahl, the goal: to create a server platform that is extensible and suitable for modern Web application Communication (ii) application at home and abroad
1.LinkedIn Mobile from RoR to node. js, base on Joyent 2. Paypal from Java to node. JS 3. Twitter queue: Collects the tweets that need to be saved and passes it to process 4 responsible for writing. Know-how push 5. NetEase 6. Ali 7. A variety of entrepreneurial teams (such as Uber). ) (c) main areas of application 1.RESTFul API 2. Real-time communication: such as message push, etc. 3. High concurrency 4.i/o Blocking (iv.) Community 1. Born in the Community 2. Community Promotion 3.Github 4. Domestic (v) Biosphere 1. In NPM Heart Node Package Manager, a Nodejs pack management and Distribution tool, has become the unofficial standard for publishing Node modules (packages). 2. Support for basic service Providers 3. Support for peripheral service providers (vi) node. JS Open source project with high visibility 1.express
2. PM2 3. Iade Node templete Engine 4. Coffee Script 5.Atom 6.socket.io 7. Pomelo 8.mongoose 9.mocha (vii) Io.js 1.Joyent target: compatibility, performance 2. Community: New features 3.io.js:a friendly fork of node. JS WI Th an open governance Model 4. Current situation: io.js development speed, has become the fastest growing open source project 5. Relationship: Full compatibility, both of which are still possible to merge the relationship between node. js and JavaScript
(i) The birth of JavaScript
1995 JavaScript Birth: Branden eich,10 Day time JavaScript target: Amateur, scripting language on browser (ii) ECMAScript and Dom/bom
1.1996-08, IE3.0 release with JScript 2.1996-11,netscape submit JavaScript to ECMA 3.1997-06,ecma-262 release 4.JavaScript = ECMAScript + do M + BOM (iii) Gmail and Google V8 1.2004-04-01,gmail released 2.2005-02-08,google maps, followed by Street View Services 3.2008-09-02,google Chrome Release , together with the V8 4.i/o block (iv) the front-end frame in the new Wave 1.DOM operation: Jquery/extjs/yui 2. Structured front-end framework: Angularjs/backbone.js/ember.js (v) run on server J Avascript's attempt 1.Rhino engine 2.javax.script API (vi) Why does node choose JavaScript? 1. Native Support Async
2. History baggage 3. Development Threshold (vii) Another implementation: FIBJS (eight) full stack language: JavaScript III, node. JS features (i) easy to deploy 1. The environment is simple to configure, just install node. js. 2. Focus on the agreement. 3. The project needs to expand, plug-ins, resources are relatively independent, not easy to conflict. (ii) Event-driven
Main point: Mobilize resources for relevant treatment based on current events. (c) Asynchronous programming
Asynchronous implementation: 1. callback function 2. Event Listener 3. Subscription release 4.i/o blocking (iv) efficiency and performance
1. The performance of a single operation is not superior to other solutions 2. Efficient by optimizing provisioning and I/O operations (other language-to-io processing: PHP: Wait in place, open multi-process C + +: Use threads, programs maintain the state of threads and resources themselves) (v) Single-threaded and multi-process
Google V8 is single-threaded, so node. JS is also single-process. To make better use of CPU resources, you can take advantage of sub-processes and multiple processes:
1. Sub-process: node. JS's Child_process Module 2. Multi-process: PM2 and other third-party tools (vi) node. JS Disadvantage 1. A large number of anonymous functions, so that the exception is not easy to read 2.try/catch limited to synchronous code, making exception capture more complex 3. Single Thread: Reliability 4. Not suitable for CPU-intensive Scenarios 5. Callback code habits affect reading
First knowledge of node. js