node. JS Learning Notes

Source: Internet
Author: User
Tags node server

Learning website: http://www.nodejs.net/a/20141016/232139.html;

Note: Describes how to benefit JavaScript as a server-side script through NODEJS Framework web development. The NODEJS framework is a V8-based engine and is the fastest JavaScript engine available today. The Chrome browser is based on V8, and opening 20-30 pages is a smooth one. The NODEJS Standard Web Development Framework Express helps us quickly build web sites that are more efficient than PHP and have a lower learning curve. Very suitable for small websites, personalization sites, our own Geek website!

Like everyone else, I started with web development, then to package management, to the development of application systems, and finally open up my own Nodejs project. Along the way, Nodejs has become the standard for my Web project. I am very willing to the original Java, PHP Web system to Nodejs migration, because 1 people can easily complete 10 people live.

node. JS is a platform built on Chrome's JavaScript runtime that makes it easy to build fast, extensible Web applications. node. JS uses event-driven, non-blocking I/O models, which are lightweight, efficient, and can work seamlessly with data at all times and on different devices.

From my experience, node has 4 great advantages:

1. Nodejs based on the JavaScript language, there is no need to learn a new language alone, thereby reducing the threshold for learning. At the same time, the JavaScript language in the Web front-end development is very important, especially HTML5 application must use, so the front and rear unified language, not only can realize the programmer's full stack development, but also can unify public class library, code standardization. On this point alone, Nodejs has won the favor of the market.

2. Nodejs did not re-develop the runtime environment, but chose the fastest browser kernel V8 as the execution engine, guaranteeing nodejs performance and stability.

3. The development of NODEJS is very efficient, and the code is simple, thanks to the Nodejs single-threaded mechanism . Another feature of Nodejs, asynchronous programming, gives Nodejs an obvious advantage in processing IO-intensive applications. Personally, using Nodejs is 10 times times more efficient than Java for web development, and simpler than PHP code.

4. The Nodejs community is growing, not only the number of packages is increasing rapidly, but also the quality of the package is significantly better than in other languages. Many star-level packages are simple and dexterous, designed for the use of developers. My most commonly used toolkit, such as Socket.io, Moment.js, Underscore.js, Async.js, Express.js, Bower.js, Grunt.js, forever.js ..., is really changing my previous programming habits.

Each language or platform has a bad domain, and for nodejs, the least adept area is CPU and memory programming.

1. Compute-intensive applications that allow JavaScript and C to spell compute performance are not likely to win.

2. Memory control makes it difficult for JavaScript and Java to compare complex data type definitions. Because JavaScript's object-oriented is JSON-based, Java uses the memory structure directly. So, with the JSON serialization and deserialization process to control memory, JavaScript has lost.

3. For large memory applications, because the V8 engine has limited memory design, the largest heap in 32-bit environments is the largest heap in the 1g,64-bit environment and less than 2G, and if you want to read 10G data at once, it will not be possible for Nodejs.

4. Static server, although the advantages of nodejs in the IO dense set application, but with nginx processing static resources still have a big gap.

5. Applications that do not need to be asynchronous: such as System management, self-scripting, or Python, Nodejs asynchronous calls can cause problems with programming.

15 Nodejs Scenarios (two first)

We have a preliminary understanding of Nodejs, and then we look at Nodejs's application scenario.

2.1 Web Development: Express + EJS + mongoose/mysql

Express is a lightweight and flexible Nodejs Web application framework that allows you to build websites quickly. The Express framework is built on the Nodejs built-in HTTP module, and re-wraps the HTTP module to the actual Web request processing functionality.

Ejs is an embedded JavaScript template engine that generates HTML code by compiling.

Mongoose is a MongoDB object Model tool that allows access to MONGODB operations through the Mongoose framework.

MySQL is the communication API that connects to MySQL database and can be used to access MySQL operations.

Web development is usually done with Nodejs, which requires 3 frameworks to work with, like SSH in Java.

2.5 Web Blog: Hexo

Hexo is a simple, lightweight, node-based static blogging framework. With Hexo we can quickly create our own blogs, which can be done with just a few commands.

At the time of release, Hexo can be deployed on its own node server, or it can be deployed on GitHub. For individual users, the deployment on GitHub is a lot of good, not only to eliminate the cost of the server, but also reduce the various system operations of the trouble (System management, Backup, network). So, the GitHub-based personal site is starting to pop up ....

Nodejs Learning Road Map

We see that Nodejs has been used in a variety of scenarios, for NODEJS application scenarios, how should we learn Nodejs?

The following is my document and tutorial, each package corresponding to an article, you can read according to their needs, a complete list of articles can be viewed: zero-based NODEJS series articles.

    • Project management: Npm,grunt, Bower, Yeoman
    • Web development: Express,ejs,hexo, Socket.io, Restify, Cleaver, Stylus, Browserify,cheerio
    • Toolkit: Underscore,moment,connet,later,log4js,passport,passport (OAuth), Domain,require,reap,
      Commander,retry
    • Database: Mysql,mongoose,redis
    • Async: Async,wind
    • Deployment: FOREVER,PM2
    • Test: Jasmine,karma
    • Cross-platform: Rio,tty
    • Kernel: cluster,http,request
    • Algorithm: Ape-algorithm (Fast sort), ape-algorithm (bucket sort)

Nodejs in the rapid development, package version upgrade quickly, the article is not available in the place please refer to the Official document resolution. I also do not update the article regularly, try to maintain the usability of the article code.

node. JS Learning Notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.