Node. js features

Source: Internet
Author: User
This article describes the features of Node. js in detail. It has good reference value. Let's take a look at it below. Node. js is a Java running platform based on the Chrome v8 engine. It is used to build a fast and scalable network application. This article will share with you some of the features of Node. js, and hope to help you learn Node. js.

Asynchronous I/O

Here, we will explain in detail:

What does Asynchronization mean?

For example, your dad wants to ask you to do something today, such as cooking, washing clothes, sweeping the floor, and boiling water. So, for example, if you finish one thing one by one, you can continue to do the next thing. For example, if you finish boiling water, then sweep the floor, sweep the floor, then cook, and cook, you may do other things. We call this process a synchronization process. You have to wait for one thing, and wait for it to finish. At this time, if we know how to arrange the time, we can do this: when we are boiling water, we can sweep the floor, because boiling water does not need to be kept! You just need to put the water in place or ignite it. Then, we can do other things. For example, we can do a series of things, such as sweeping the floor or washing the clothes. In this way, the same thing is done, but the time it takes is different. If you use this method later, the time may be shorter and the efficiency will be higher. You can use the aforementioned synchronous method to achieve lower efficiency. In the future, we will call it an asynchronous operation.

Events and callbacks

If you use an Asynchronous Method to do things, it will be very efficient, but you can only do one thing at the same time. For example, when you boil water, you do not need to stay there. But how do I know when you boil the water? (How do I know after this is done ?)

So we can think about it, put a small horn on the kettle, and steam will take off when the water is burned. When the steam blow the horn, we will know that this is done well, and the water is burned out, we can continue to do things after the water is burned out.

This event and callback are: After the water is burned, it will notify you in the form of an event (I have done this well, you can install this water ).

What does callback mean?

When an event occurs, it will notify you that you are in the water process, that is, callback (that is, processing this process ). Processing results after boiling water

Single thread

This is a big feature of node. js. It can develop efficient background applications (network applications)

What is a single thread?

Use the example just now. Your dad asks you to do a lot of things. If you don't know how to arrange the time properly, you can only use synchronization. When synchronizing, you may think like this: I asked some of my friends to help me do this (two or three friends ). One will help me boil water, one will help me sweep the floor, and the other will help me cook. In this way, multiple people will help you do things in the same period of time. (This operation is called a multi-threaded operation, that is, there are multiple people doing things in the same time period)

The disadvantage of multi-threaded operations is that if you ask these friends to help you do things, you must reward them, so you will inevitably spend your pocket money, you must buy something delicious to treat yourself. So what do you do if you don't want to spend your money but want to do well? You can only do it by yourself in asynchronous mode. What should we do to improve efficiency? That is, when I am doing this and other things at the same time, this is a single thread (that is, a person doing things ).

Cross-platform

Currently, node. js can run on mac, Windows, and Linux. It has been developed in addition to the corresponding runtime environment.

The above is all the content of this article. I hope this article will help you in your study or work, and I also hope to support PHP!

For more details about Node. js features, refer to the PHP Chinese website!

Related Article

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.