Table of Contents
10 comparison challenges between PHP and Node.js
Home Backend Development PHP Tutorial 10 Comparison Challenges between PHP and Node.js_PHP Tutorial

10 Comparison Challenges between PHP and Node.js_PHP Tutorial

Jul 13, 2016 am 09:45 AM
node.js php

10 comparison challenges between PHP and Node.js

In a recent SitePoint PHP vs Node.js Smackdown article, Craig Buckler compared how the two languages ​​addressed a series of 10 challenges to determine which one was better overall.

Craig says in the book that these comparisons are always somewhat contradictory. As a fun follow-up, we asked Bruno Škvorc (a PHP developer at SitePoint) and James Hibbard (a JavaScript developer at SitePoint) to provide comments on each round.

The following are their detailed views...

PHP 和 Node.js 的角摔

Round 1: Start

Round 1 The challenge is to see how fast you can build a "Hello World" page in each language. This includes the time spent setting up the server environment.

In Craig's estimation, PHP won this round in part because the language was "conceptually simpler" and "less intimidating to new developers."

Bruno:

PHP wins the "Start" round purely because more hosts support the language so it's very easy to get started. It's ready to use without having to do anything extra. If more hosts ignored using the Node command line and went straight to file uploads and a simple "reload app" key on the control panel, both would be the same. However, in terms of the actual syntax for displaying things on the screen, PHP is simpler - especially for those with no programming experience.

James:

I don't see a huge difference between the two when developing on my local machine. To run PHP scripts in your browser, you need to install some server software; to run Node scripts, you need to install Node, and preferably a web framework such as express. However, as Craig said, PHP is "conceptually simpler ”.Node has a higher barrier to entry. There is no dispute about this.

Round 2: Help and Support

The second round will consider how easy it is to get help and support in both languages. PHP wins this round mainly because it has been around longer.

Bruno:

Keep quiet about this.

James:

I agree with this statement. Node is a new technology, so for now, there will be less help. But when Node becomes more and more mature, this aspect will not be a problem.

Round 3: Grammar

The third round compared the ease of understanding the grammar of the two languages. Craig decided that Node won this round.

Bruno:

I strongly disagree with this point of view. There are indeed some quirks in PHP syntax, many of which have been fixed, and many more will be removed in new versions. On the other hand, there is also the problem of "this" in JS~

Regarding bullet 3 (when developing, you don’t need to switch between client-side development and server-side development when using js), I don’t agree with this concept. The server environment and the client development environment are completely disconnected, and switching in the brain is still needed. There's always some new syntax that you can't use in the browser and vice versa, so it's also a language switch in a way.

Bullet 4 (Understanding JS makes you want to use it more) I agree with this to a certain extent. I've been using JS and PHP at work for many years, and JS for even longer, but I have little fondness for it - although that's purely a personal preference.

James:

I love JavaScript. I know it has its quirks, and I know for some reason that ECMAScript 2015 will shake things up and bring some exciting new features to the language. JavaScript is powerful and flexible, and can accommodate many different styles of programming. I enjoy using JavaScript as opposed to PHP. NodeNode.js) is one of them.

Round 4: Development Tools

Round 4: Considering the development tools used by these two technologies, Node is slightly better because it has the development tool npm.

Bruno:

Although, developers were initially inspired by npm, now there are leaps and bounds which are more comfortable to use than npm, and if you have two versions of the same library installed on your computer, leaps and bounds will not let you system crashes. And compared to npm, leaps and bounds allow designers to use recursive thinking, and recursive thinking is so important that when developers are ready to build a package manager, this is the first thing they consider.

npm also has a fatal flaw, which I call "developer collaboration friendliness". npm cannot do this well. For npm, only the developers themselves can understand what they write. Finally, npm does not play well with Vagrant, which directly prevents you from starting to work on your own, not to mention that npm does not pay attention to the needs of users. There is a bug in npm that has existed for many years, which makes the software basically unusable on windows, which is not a small problem. Of course PHP has a lot of stupid bugs, but these bugs won't cause problems on your system.

It's true that PHP doesn't come with a compiler, but I don't think it should. Such convenience should not be accomplished by a package manager or a standalone application. If one day someone develops a good package manager for Node, it will be extremely difficult to replace it with the existing compiler. Make it relatively independent and people can switch easily. Furthermore, installing it only requires typing a line of code into a terminal, or downloading an installer.
The statement in the book that the compiler has little impact is an obvious mistake. Since PHP was developed, the compiler has impacted every new PHP developer who has joined, and some of the best of them have had to add it to their existing pipeline. Just because there were many PHP users before the compiler existed doesn't make it any less useful. In fact, since its introduction, it has had a huge impact. The claims made by some that there would be "little impact on the community" have no basis in fact at all.
Now, I can't argue with the fact that most PHP developers want Node installed, that's a true fact. Sadly, many good tools were first developed based on Node, but I still hope that just like the Node-free development environment, it can also be used to develop BowerPHP.

James:

I’m excited to have people join Node.

I like npm. It's easy to install, easy to use, and has thousands of packages available for almost any need. I also like the fact that npm can select global and local packages (compared to some languages ​​like Ruby where the standard requires your packages to be installed alongside your version of Ruby). Its tools are great too. Some tools, like Bower and Grunt, have a permanent place in my workflow and have increased my productivity exponentially.
It is also worth mentioning that npm has developed a beta version of version 3. It solves many of the problems Bruno mentioned, such as nested node_modules method errors, etc.

The following is quoted from entire smackdown:

PHP developers may want or need) to install Node.js on certain occasions. The converse is not true.

Round 5: Environment

The fifth round is about the availability and deployment of the technology, as well as which platforms and ecosystems support it. Craig isn't very clear on this, but seems to favor Node.

Bruno:

Craig said he had compared the advantages of PHP and Node on the web (Common web development questions), and then said that JS is used everywhere. First, we compare Node.js, not JS itself, and second, we compare the environments in which both languages ​​can run. Monkeys are stronger than fish because fish are too stupid to climb trees, but both monkeys and fish can swim. So let’s compare how well they do.

In web development environments, PHP wins. Here are some PHP-based desktop program tools - yes, maybe you won't use them, but you will definitely use these PHP-based command line programs.

James:

Once again, Craig and I are on the same page. Some of the features that have made Node.js so popular (speed, scalability, tight connection to JSON, low resource footprint) make it suitable for many other types of applications, such as powerful IoT devices. I think, who doesn’t like robots?

Node empowers projects such as NW.js (an application based on Chromium and Node.js), which allows you to write native apps on HTML and JavaScript. How exciting!

Round 6: Integration

In round 6, let’s take a look at the integration of databases and drivers. PHP wins mainly because it is older.

Bruno:

In terms of integration, it is actually a tie. PHP has the advantage of age and can have more options, but it also means taking care of a lot of outdated technologies, such as mysql extensions - we can upgrade to PHP7 to get rid of it, but it has been Not available.

James:

I certainly agree with this, even though it seems vague, and I like this example: "obsolete, more popular technology". This also highlights a great advantage of Node - its native support for JSON. JSON is perhaps the most important data transfer format on the web and is the common structure for the latest NoSQL databases. It is very easy to use JSON in JavaScript programs, which means that when you work with Node, the data can be transmitted very concisely, without the need for format conversion. You can use only one syntax (JSON format) to pass between the browser, server and database.

Round 7: Hosting and Deployment

The seventh round will look at how easy it is to deploy a new application to a web server, and in Craig's opinion, PHP is the clear winner in this regard

Bruno:

Bruno remains silent once again.

James:

This is an area Node needs to work on. Every company that offers web hosting offers PHP and MySQL. If you want to see the output, you only need to create a file with a ".php" extension, write some valid code between , upload it, and access it with a browser. But the same method does not work for Node. Of course, there are many options for Node hosting, but they require more setup and command-line access, which can be unpleasant for beginners. There is no doubt that PHP won this round.

Round 8: Performance

The eighth round focuses on speed. While this often comes down to experience and how dedicated the development team is, Craig noted that Node has advantages in some areas.

Bruno:

Errors abound. First, this article has a detailed discussion of performance, which excludes the impact of developer experience and application type on performance. If that article still doesn’t make you understand how foolish it is to talk about performance without context, let me share my opinion:

  • PHP is embedding a multi-threaded server. This makes it possible to completely bypass the external server, but it is not recommended yet. There are also some super-fast servers like Nginx), which make the entire process of starting PHP and dispatching requests so fast that it can be ignored.

  • PHP’s native asynchronous (non-blocking I/O) support will be introduced in PHP7, and ReactPHP implemented a similar pattern years ago, so this also makes no sense.

  • PHP single-request life cycle mode is the biggest burden. Indeed, if you are purely pursuing speed, this can still be easily bypassed, not only through Memcached and similar methods as Craig said, but through methods similar to Ajax. By the way - server-side JS applications are also single-request by default. In addition - this single-request life cycle is also an advantage. The application is rebuilt for each request, avoiding many memory problems, clearing garbage memory, and keeping it slim and clean. When was the last time you used a stable, long-running, memory-leak-free Javascript application, front-end or back-end?

The performance discussion is, and will always be, a draw unless you are using Java, then Java loses)

James:

Node is known for its high-performance and low-latency runtime environment, and it has also found its own way to be embedded in the code stacks of some Fortune 500 companies. Thanks to its non-blocking I/O mechanism and Google Chrome V8 engine technology, Node has now become synonymous with "fast" and "scalable". There are many stories on the Internet now, such as how Node allows companies to obtain better performance improvements and provides developers with higher productivity. I'm happy that node won this round, but I also understand that some people question this.

Round 9: ProgrammerComplex

Let’s take a look at the ninth round to see how much affection Craig thinks the average programmer has towards PHP and Node. In the end, he thinks Node won.

Bruno:

You are definitely looking at the wrong place, Craig, the PHP community is incredibly passionate and active, with over 20 conferences a year and fantastic topic discussions. This is how HHVM's PHP7 was completed.

Also, I would like to say that I am curious which version the Node developers are working on (v0.12.5 has already been written), even after 6 years of development. This is immature and dangerous. Oh my God, you are using an unstable technology, are you deliberately letting your business fail?) Plus, it ignores some old bugs in the operating system and will lead to some important of developers are leaving the language ecosystem.

Some negative experiences have made me dislike Node, mostly because of npm. That may change in the future, but right now every time I use Node I feel scared and disappointed. We all have our preferences, but it's important to stay objective and choose the right tool for the job. But it’s also important to allow others to try and make mistakes, because everyone is doing it in hindsight. So don’t listen to Craig, don’t listen to Jim, and don’t listen to me. Go ahead and experiment, see what works, and find what feels good to use. Ultimately, the best ones are the ones that make you feel productive, not the ones that just save some load time.

James:

Node is very popular, and there are a lot of innovations in the field of Node. Although passion is not objective, I am glad that Node won this round.

Round 10: Future

Round 10 looked at the prospects of both languages, and with both languages ​​looking to have a strong future at this stage, Craig concluded that the outcome of this round was a draw.

Bruno:

Bruno has to hurry up and write more articles about PHP and maintain the amazing SitePoint PHP channel.

James:

James also can’t wait to get back to his beloved JavaScript channel, but he left these comments:

A draw is fair for this round. Node is a rising star, but it has a lot of work to do if it wants to dethrone PHP.

In summary, if a hammer is your only tool, every problem looks like a nail. Node is not perfectly suitable for every solution. Of course, it is very reasonable not to use Node in many cases. However, what Node can do, it can do extremely well. It's entirely up to you to make an informed decision and choose the best tool for your project.

Now that Bruno and James have expressed their opinions, what do you think of this issue?

Bruno Skvorc

Bruno, a Croatian programmer, holds three master's degrees in computer science, English and literature. He is a PHP columnist for SitePoint and a development evangelist for Diffbot.com. He avoids legacy code like the plague and picks projects that use the latest technology. He is also a treadmill desk enthusiast and gamer. He has a blog: sometimes blogs.

James Hibbard

I am a website developer currently living in sunny northern Germany. I love programming in JavaScript and Ruby, and you can often find me on SitePoint's javascript forum. When I'm not coding, I enjoy running.



www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1043400.htmlTechArticle10 Comparative Challenges of PHP and Node.js In a recent article on SitePoint’s PHP vs Node.js Smackdown, Craig Buckler compared how the two languages ​​addressed a series of 10 challenges...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1253
24
PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

The Enduring Relevance of PHP: Is It Still Alive? The Enduring Relevance of PHP: Is It Still Alive? Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP vs. Other Languages: A Comparison PHP vs. Other Languages: A Comparison Apr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

See all articles