Nodejs Study Notes (i)--First knowledge NODEJS

Source: Internet
Author: User
Tags call back

Preface: At present the work of mightily is relatively single, hope can through the time of the work to charge oneself, just do not have a study companion or big God belt, can only say is groping forward. At first, ready to study the framework of Spring, download the source code, combined with the book to find out, see how Spring loaded beans, and how to convert to their own data format, and so on, although not yet involved in the actual combat, is considered to be some of the confusion encountered in the previous work to help. Total ready to write a blog to show my "Big Data Small World" blog is not long grass too deep, but later chance coincidence, want to know about the crawler kind of things, spring first do shelve.

In the degree of Niang Search Crawler, the overwhelming variety of technology into the eye, and the Python especially scrapy most eye-catching, with the past has used Python to write an experimental calculation program one side, know that this script entry threshold is not high, approachable, He found a data, ready to enter Python. A week to understand, read some basic grammar, and matlab Some of the syntax is closer.

But later, and some small partners to discuss, can consider the recent killing out of the Dark horse Nodejs, is very eye-catching. The basic starting point is the Nodejs Grammar and JavaScript consistent, just take this opportunity to learn the next JS, but also for JS from another point of view to a good understanding. (Too much nonsense, in short, explain two points: 1. Why the blog has not been updated for a long time; 2. Today and later is about Nodejs)

Originally prepared to write an article, but after the completion of the text found that the length seems to be split into two more appropriate ~ ~ ~

Originally for JavaScript is a small white, of course, for Nodejs even small white is not counted. Although previously read the "JavaScript authoritative guide" and studied Angularjs, but after all, because of the lack of application scenarios, always with JS relationship is aloof.

The name of JavaScript who men who, a very humble at the beginning of the client programming language, node believe that you are also heard of it, can be said to be a platform JS server. About Nodejs can look at the explanation on Baidu:

  node. JS is a platform built on the chrome JavaScript runtime to easily build responsive, easy-to-scale Web applications. node. js is lightweight and efficient with event-driven, non-blocking I/O models and is ideal for data-intensive, real-time applications running on distributed devices.

In addition, Nodejs is a single-threaded , high-concurrency , non-blocking platform. Single thread? High concurrency? How to explain???

I understand that this is due to the callback mechanism of node and the asynchronous processing mechanism .

  Some people ask, what is a callback mechanism (function); What is synchronous/asynchronous; What is blocking/non-blocking ....

Take a look at an example of what the online Scott teacher said:

  Requirement Scenario 1: You want to go out dashing, ready to set a restaurant, Huchihaihe, so picked up the phone to call the Sha County snacks on the card, asked: "Boss, you still have a position now, I want to bring friends to dinner

  Sync : The boss said, OK, don't hang up your phone, I'll go and see ... (synchronous means: sequential execution, until the boss comes back and says whether there is a seat, the event is over before the next event can be executed )

Requirement Scenario 2: same 1

  Async : The boss said: OK, I have a guest on this side to check out, I'll take a look at you, and then call you back, then hang up the phone. (Async is the boss know this order, but can go to see if there is a seat or immediately to see if there is a seat, the phone can be casual boss when back, and in this gap, the boss can do a lot of things, such as to the guests to check out or arrange to enter the shop guests sit and so on, unlike the scene 1 must only go to Because the phone is not hanging)

  callback : The boss gave me a call back.

Block : I was in scene 1, except anxiously waiting for the boss to come back to me, I can do nothing. After the boss came back and gave me a message about the seat, I hung up the phone before I could do anything else.

non-blocking : In Scene 2, the boss said, call back later. Then I don't have to think of a fool where I can hold the phone and wait. I can do other things, such as informing friends and classmates who are going to share a big meal tonight.

These are some of my personal opinions, if there is a false and misleading, I beg to correct, but not fraught.

With these concepts, to think about single-threaded, high concurrency will not feel so contradictory, this is also the reason node can be popular.

About the Nodejs syntax, is nothing more than JS. Of course, it seems to me that it takes time to get familiar with node, which is a lot of "random" and incredible features compared to Java.

background :   My Machine node and NPM have been installed (in Windows), and environment variables have been configured. Git Bash is already installed.

This article focuses on the small issues encountered during the construction of the node environment and the prerequisite steps to build the Eclipse Development node environment.

  1. for cases where the setup process through NPM is slow or even unresponsive:

You can do this by entering NPM install-g cnpm--registry=http://registry.npm.taobao.org on the command line, and then by entering CNPM Install < The module you want to install > To complete the installation.

2. originally wanted to build a node development platform on the MyEclipse installed on this machine, but it may be that the version is too old, many operation is inconvenient, download the latest eclipse.

  2.1 First need to install three plugins:

  Help->install New Software


  node. JS Plugin--Nodeclipse

Update Address: Http://www.nodeclipse.org/updates

  

This is not FQ in the case of a slow reaction, the following link seems pretty fast: http://dl.bintray.com/nodeclipse/nodeclipse/0.6.0/

JavaScript Editor Plugin--Vjet
Update Address: http://download.eclipse.org/vjet/updates-0.10

Google V8 plugin (debug prerequisites)
Update Address: http://chromedevtools.googlecode.com/svn/update/dev/

2.2 After completing the above installation, restart Eclipse, and then you can create a new node project.

2.3 The newly created Robotproject project as shown in

So far, the necessary plugins have been installed in Ecliplse and a new node Project can be created in eclipse, but this is not enough: one cannot run, two cannot debug, want to know how to realize, see next article ~ ~ ~

  If you feel that reading this article is helpful to you, please click " recommend " button, your "recommendation" will be my biggest writing motivation! If you want to keep an eye on my article, please scan the QR code, follow Jackiezheng's public number, I will push my article to you and share with you the high-quality articles I have read every day.

  

Nodejs Study Notes (i)--First knowledge NODEJS

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.