What are the advantages of php and nodejs? if there is no foundation, what should I do?

Source: Internet
Author: User
Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming... Reply content: the first time I answered the question, I think it's a little excited ~
I have been engaged in Node. js development for the time being. I have been a little touched by PHP before. this answer is true of the incorrect language.

First, I will post two pictures to intuitively feel the charm of the two languages. next I will talk about my understanding of these two languages.
The first one is the simple transaction rollback module I wrote for mongoose using Nodejs.
The second is the routing module similar to the Express framework I wrote in PHP.


1. Syntax
I believe that after reading the two pictures above, the most intuitive feeling for the two languages is that the syntax is quite different.
First, let's talk about PHP.
The unique PHP syntax is a mix of C, Java, Perl, and PHP self-innovative syntaxes.
The above sentence is taken from Baidu Encyclopedia. The PHP syntax is recognized as a unique syntax. it is a collection of hundreds of experts and can be further innovated. Those who have studied OO will feel more cordial about this. However, I cannot bear the fact that PHP variable names must be preceded by a $ symbol.

As for Nodejs, Node itself is the Javascript language. for Web front-end scripting developers, learning Node is just like a fish. Javascript, as a scripting language, has great freedom in coding (Voiceover: PHP is also a scripting language !), However, the asynchronous encoding style of Javascript does not help beginners who want to learn the synchronous encoding style.

In terms of syntax, I prefer Nodejs (after all, 233333 of Javascript code is written ). PHP is too tired for Chen ~

2. efficiency
There is no need to compare this,
Question about Web language efficiency: PHP or Nodejs
Let's take a look at what I said on the first floor.
With the efficient V8 engine and its non-blocking asynchronous I/O features, Nodejs far outperforms other ScriptLanguage.
Node. js is 14 times faster than PHP!
This is a much more efficient analysis here. Of course, I am not pursuing Nodejs.
This is not a battle for simple language details, but a battle for language frameworks. Moving Node. JS asynchronous mechanisms from ctictipt to PHP. NET Java in other languages will actually be dozens of times more congested.

3. Use cases
Undoubtedly, both languages are born for Web development. Various built-in PHP methods and libraries make Web development extremely convenient and efficient. mature language frameworks also provide developers with high robustness and stability. With its powerful features, Nodejs attracts a large number of developers to contribute their extended libraries. Although the Nodejs project is still very young, it has gathered a large number of development resources.

4. Summary
After all, I know little about PHP, so it is inevitable that the above comments are somewhat biased towards Nodejs. However, if PHP has been developing for many years, it must be true. Baidu still uses PHP.
As for Nodejs, as a new language (not new, Javascript is much older than PHP), its unique design features attract developers to read it.

I finally returned to the question subject's question. I don't know if the subject says that there is no foundation, that is, there is no foundation for programming or server development?
If there is no programming foundation at all, I suggest you study the C language first, enter this line first, and then select the tool ~
If you have a programming Foundation, if you have learned OO before, you are advised to start with PHP first. after all, it is easier to transition, and there is much more information about PHP on the network than Nodejs.
If I have learned Javascript before, I suggest starting with PHP first. as mentioned above, I first entered this line and then selected the tool. Server development is also a small step. if you do not know about server development and network mechanisms, you should first start with PHP and add the relevant knowledge.
If it is really attracted by the advantages of Node. js, I suggest you study Javascript advanced programming and have a deep understanding of the different prototype chain and callback mechanism, which will be of great help to start with Node. js.

Be cautious when entering the line. you can't climb through the pitfalls ~

I don't produce answers. I'm just the answer Porter! Most of the above are taken from the network. No basics for PHP. The simplest.
The Node. js event mechanism is not suitable for beginners. The php engineer will ask you to learn php, because he will say that php is the best language in the world! PHP without any foundation
Using LAMP, I suppose you want to develop a website. Otherwise, skip the following answer.

No basic suggestions start with PHP.

More than 60% of the world's websites are developed using PHP.
Then you should learn Javascript, which is used in the dynamic part.

Noje. js relies on the Javascript syntax. if you use Javascript, you can learn better.

When the website is large, it generally uses the Java/Scala language, because PHP needs to explain and execute the script, and the speed is not as high as the byte code after Java compilation.

Summary: PHP + JS => Java + JS.

Finally, if you have time and interest, take a look at Scala, Go, Rust, and other latest languages in the industry. Thank you. Node. js. By the way, you can write a website by learning html css ~ I have never used PHP.

If you do not have any language basics, we do not recommend that you directly use nodejs. Or start from other standard back-end languages with object-oriented, MVC frameworks. Ruby, Python, and Php are the first choice. laying a solid foundation is the key.

When a newbie goes up and sees the implementation of functional classes, it is estimated that most of them will be dizzy except for the talented ones. JS class implementation is not so "standard ", it is confusing for you to understand object-oriented.

If nodejs is used as soon as possible, you may be confused about what the request, response, and response header in the createServer function are passed. Because you do not have MVC experience, do not know what the Web framework, templates, and so on are, and JS object-oriented implementation is not so "standard", there are not many node materials, basically, there are not many Chinese documents, which may be difficult to learn.

If you have other object-oriented language basics (not required ). JS syntax 3 days, node get started 1 day, directly look at the api and the source code of some node frameworks, of course, to be skilled, that is another matter. I think the corresponding application scenarios are different. NodeJS should be mainly applied to web services with fewer transactions and NoSQL databases to achieve great performance. Socketio web chat is also an application scenario of Node.
PHP applications are relatively good at displaying web pages. PHP development is also fast and can be used for rapid prototyping and continuous iteration. The efficiency is not very low.
Nodejs is harder to learn than php. Moreover, the asynchronous callback style is easy for people to step on. In addition, nodejs debugging is not convenient.
To sum up, we recommend Python. Nodejs is not easy to write. it is easy to enable the brainless mode when writing php in PHP first, but the function name and parameter location are not uniform, which is really disgusting. Write node, amount ......, Forget it, or use Java.

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.