What are the advantages of PHP and Nodejs, and if there is no foundation to start with, learn that good?

Source: Internet
Author: User

Reply content:

First answer, think of a little excited about it ~
I have been engaged in NODEJS development, before a slight contact with PHP, the answer to the question is not language, extremists do not like to spray.

First put two pictures, first intuitively feel the two languages different charm, after I came to talk about my understanding of the two languages.
The first one is the simple transaction rollback module I wrote for Mongoose with Nodejs.
The second one is a routing module that I wrote in PHP similar to the Express framework.


1. Syntax
Believe that read the above two pictures, for the two languages the most intuitive feeling is that the grammatical difference is very large.
First of all, PHP.
PHP's unique syntax mixes C, Java, Perl, and PHP's self-innovative syntax.
The above sentence is taken from Baidu Encyclopedia. PHP syntax is recognized as a relatively unique grammar, set the length of hundreds of families, and then innovation. Students who have studied OO will be very friendly to this. However, for my not long PHP coding experience, I can not bear the point is that the PHP variable name must be preceded by a $ symbol.

As for Nodejs,node itself is the JavaScript language, for Web front-end scripting developers, learning node is a duck in the head. JavaScript, as a scripting language, has a great deal of freedom in writing code (voiceover: PHP is also a scripting language okay!). , but JavaScript's asynchronous coding style is really a way for students to get started with the language of learning to sync coding styles.

In terms of grammar, I tend to be more nodejs (after all, 233333 of JavaScript-born). PHP is too tired for my concubine to write

2. Efficiency
There's really no need to compare that.
Web language efficiency issues, PHP or Nodejs
Look at the big talk on the first floor here.
With its highly efficient V8 engine and its non-blocking asynchronous I/O features, Nodejs is far more efficient in its execution than other ScriptLanguage.
node. JS is 14 times times faster than PHP!
Here this greatly in the efficiency of the analysis of more in place. Of course I'm not chasing Nodejs, just like this big-talk
This is not the simple language of the dispute, but the language frame of contention. Moving the asynchronous mechanism of node. js from Javasctipt to other languages PHP. NET Java will actually get dozens of times times better than the original blocking method.

3. Usage Scenarios
Undoubtedly, both languages are born for Web development. PHP's diverse built-in methodologies and libraries make web development extremely convenient and efficient, and the mature language framework provides developers with a high level of robustness and stability. While Nodejs has attracted a large number of developers to contribute to the expansion of its library, the Nodejs project, although still young, has gathered a lot of development resources.

4. Summary
After all, there is less understanding of PHP, so the above remarks are inevitably a bit biased in favor of Nodejs, but the development of PHP for many years is sure to have its reason, Baidu also use PHP.
As for Nodejs, as a burgeoning (not new, JavaScript can be much older than PHP) language, its unique design features enough to attract developers to see it.

Finally back to the question of the main problem, do not know the title of the main said that there is no basis for programming or server development basis?
If there is no basis for programming, I suggest that the master or the first to learn the C language, first into the line, and then choose Tools Bar ~
If there is a programming basis, if the previous learning Oo, it is recommended to start with PHP, after all, it is easier to transition, and the network of PHP more than Nodejs.
If I had learned JavaScript before, I would suggest starting with PHP, as mentioned above, first in this line, and then in the tool. Server development is also a small line, if the server development does not understand, the network mechanism does not understand, start with PHP, the relevant knowledge to add up.
If you are attracted by the advantages of Nodejs, I suggest that you learn JavaScript advanced programming and understand the different prototype chain and callback mechanism in depth, which will be very helpful for starting Nodejs.

Need to be cautious in the entry, not to climb out of the pit AH ~

I don't produce the answer, I'm just the answer to the porter! Most of these are from the Internet. No basic PHP. The simplest.
The Nodejs event mechanism is very inappropriate for beginners. PHP engineers will ask you to learn PHP, because he will say that PHP is the best language in the world! There's no basis for PHP.
Walk the LAMP system I assume you want to develop a website. Otherwise, skip the following answer.

No basic recommendations start with PHP.

60+% more than the world's Web site with PHP developed, has his own truth.
Then you should learn some JavaScript, and the dynamic part needs to use it.

Noje.js relies on JavaScript syntax, if you will JS, then start to learn a little better.

After the site is large, it will generally use the Java/scala language, because PHP needs to interpret the execution script, which is slower than the Java compiled bytecode.

Summary: PHP + js = Java + js.

Finally, if you have time and interest, you can take a look at the latest language in the Scala/go/rust and other industries. Thank you. Nodejs Bar, JS by the way will be, and then learn HTML CSS can write Web site ~ I have not used PHP.

If you have no basis for any language, you are not advised to go directly to Nodejs. Or to start touching the object-oriented, MVC framework from other standard point back-end languages. ruby,python,php first Choice, lay a good foundation is the key.

Novice to see the function of the class implementation, except that the majority of gifted better will be dizzy, JS class implementation is not so "standard", for you to understand the object-oriented is confusing.

If you come up with Nodejs, you may wonder what the request,response is to createserver that function, and what the response response header is. Because you do not have the MVC experience, do not know the web framework, the template and so on what is the object, and JS's target-oriented implementation of the less "standard", node is not much information, basically there is not much Chinese material, learning may be difficult.

If you have other object-oriented language basics (don't need a level too much). JS Syntax 3 days, node to get started 1 days, directly look at the API and some node framework source bar, of course, skilled that is another matter. I think the corresponding application scenario, Nodejs should be mainly used in less transactional Web services, with a NoSQL database, to achieve great performance. and socketio implementation of Web chat is also a node of the application scenario.
PHP applications are better at rendering Web pages. PHP development is also fast, can be used for rapid prototyping, continuous iteration, the efficiency is not very poor.
Nodejs is harder to learn than PHP. And the asynchronous callback style is easy to trample on. And the Nodejs debugging is not convenient.
In summary, Python is recommended. Nodejs not easy to write, start the PHP bar to write PHP can enable the brain-free mode, good convenience, but the function of the name, parameter location is not uniform, indeed disgusting. Write node, the amount ..., forget it, or just use Java, (escape
  • 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.