PHP and Node.js's 10 comparison challenges

Source: Internet
Author: User
Tags end file upload mysql new features php and php and mysql version install node

In the recent sitepoint of PHP vs Node.js SmackDown, Craig Buckler A comparison between the two languages on how to deal with a series of 10 challenges to determine which is better overall.

These comparisons are always contradictory, Craig says in his book. As an interesting follow-up, we asked Brunoškvorc (SitePoint's PHP developer) and James Hibbard (a JavaScript developer in SitePoint) to provide comments for each round.

Here is their detailed view ...

First round: Start

Round 1 challenge is to see how quickly you can build a "Hello World" page with each language. This includes the time it takes to build a server environment.

According to Craig estimates, PHP won this round partly because the language was "conceptually simpler" and "less scary for new developers".

Bruno:

PHP won the "start" round simply because more hosts support the language so it started very simple. This is what it takes to make it work without having to do anything extra. If more hosts ignore the Node command line and use the file upload directly, and use a simple "Reload app" button on the control Panel, the two will be the same. However, PHP is simpler in terms of the actual syntax for displaying things on the screen-especially for those who have no programming experience.

James:

When I was developing on the local machine, I didn't see a big difference between the two. Run the PHP script on your browser, you need to install some server software, to run the node script, you need to install node, and it is best to install a Web framework such as Express. However, as Craig says, PHP is "simpler conceptually". Node's entry threshold is higher. There is no dispute about this.

Second round: Help and support

The second round will consider how easy it is to get help and support in both languages. PHP won this round, mainly because it appeared longer.

Bruno:

Keep silent about this.

James:

I agree with this statement. Node is a new technology, so at present, help will be less. But when node becomes more and more mature, this is not a problem.

Third round: Grammar

The third round compares the degree of difficulty in understanding the grammar of the two languages. Craig decided that this round of node wins.

Bruno:

I disagree very much with this view. There are some strange images in the syntax of PHP, many of which have been fixed, and in the new version, there are many to be removed. On the other hand, JS also has the question of "this" ~

About Bullet 3 (development, use JS you do not need to be in client-side development and server-side development when switching), I do not agree with this concept. The server environment and the client's development environment are completely out of place, and switching in the brain is still needed. There's always some new syntax you can't use in browsers, and vice versa, so this is a language switch to some extent.

Bullet 4 (Understanding JS will make you want to use it) in a way I agree. I have used JS and PHP for many years in my work, using JS longer, but I like very little about it-although it is purely personal.

James:

I love JavaScript. I know it has its quirks, and I know some of the reasons why ECMAScript 2015 will be modified and bring some exciting new features to the language. JavaScript is powerful and flexible and adaptable to many different styles of programming. In contrast to PHP, I enjoy using JavaScript. Node (Node.js) is one of them.

Fourth round: Development tools

Round 4: Consider the development tools used by both technologies, and Node is slightly because of the development tools NPM.

Bruno:

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

NPM also has a fatal flaw, which I call "developer collaboration-friendly", which NPM doesn't do well, and for NPM, only the developers themselves can understand what they're writing. Finally, NPM and vagrant are not very compatible, which directly prevents you from starting your own work, not to mention that NPM doesn't care about the needs of users. NPM has a bug that has been around for years, and it makes the software almost impossible to use on Windows, which is not a small problem. Of course, PHP also has a lot of stupid mistakes, but these errors do not have a problem with your system.

Indeed, PHP does not have its own compiler, but I don't think it should. Such a convenience should not be done by a package manager or an independent application. If one day someone develops a good package manager for Node, it will be extremely difficult to replace it with the existing compiler. Let it be relatively independent, people can easily switch. In addition, installing it requires only one line of code to be entered on the terminal, or download a setup program.
The compiler mentioned in the book has a very small effect, and it is an obvious mistake. Since the PHP development is complete, the compiler has influenced every new PHP developer to join in, and some of them have had to add it to the existing process. There are many reasons for PHP users to be based only on the existence of a compiler, and it does not show that it works less. In fact, it has had a huge impact ever since it was created. What some people call "little impact on the community" has no basis in fact.
Now, I can't argue with the fact that most PHP developers want to install Node, which is true. Sadly, many good tools are developed first based on Node, but I still want to be able to develop bowerphp like node-free development environments.

James:

I'm glad someone joined node.

I like NPM. It is easy to install, easy to use, and has thousands of packages available for almost any need. I also like the fact that NPM can choose a global and local package (by contrast, some languages like Ruby, whose standard needs to install your package next to your Ruby version). It's also a great tool. Some tools, such as Bower and grunt, have a fixed position in my workflow, and they multiply my productivity.
It is also worth mentioning that NPM has developed a beta version of the 3rd edition. It solves Bruno's reference to many problems, such as nesting node_modules method errors, and so on.

The following references are from entire smackdown:

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

Fifth round: Environment

The 5th round is about the availability and deployment of technology, and what platforms and ecosystems support it. Craig is not quite sure about this, but it seems to be more of a Node.

Bruno:

Craig says he used to compare PHP and Node's web-related advantages (common web development issues), and then said JS was used everywhere. First, we compare the node.js, not the JS itself, and secondly, we compare the two languages in what environment can be run. Monkeys are more powerful than fish, because fish are too stupid to climb trees, but monkeys and fish can swim. So let's compare how well they're doing.

In the Web development environment, PHP wins. Here are some PHP-based desktop program tools-Yes, maybe you won't use them, but you will certainly use these PHP based command-line programs.

James:

Once again, Craig and I agreed. Some of the features that make node.js so popular (speed, scalability, close to JSON, low resource footprint) make it suitable for many other types of applications, such as powerful IoT devices. I think, who would not like the robot?

Node enables projects to be upgraded, such as Nw.js (a Chromium and node.js based application) that allows you to write native apps on HTML and JavaScript. How exciting!

Sixth round: Integration

6th round we take a look at database and drive consolidation, PHP wins mainly because it's older.

Bruno:

Integration is actually a draw, PHP has an age advantage, can have more options, but also means to take care of a lot of outdated technology, such as MySQL extension-we can upgrade to PHP7 to get rid of, but for many years has not been available.

James:

I certainly agree with this view, which seems to obscure its words, and I like this example: "Outdated, more popular technology". This is also a great advantage for node-it natively supports JSON. JSON may be the most important data transfer format in the Web, and it is also the most common structure for the latest NoSQL databases. Using JSON in a JavaScript program is very easy, meaning that when you work with Node, the data can be transmitted very succinctly without the format conversion. You can use only one syntax (JSON format) to pass between browsers, servers, and databases.

Seventh round: Host and deployment

The seventh round will see if it is easy to deploy new applications to a WEB server, and in Craig's view, PHP is clearly a winner

Bruno:

Bruno remained silent once more.

James:

This is the area where Node needs to improve. Each company that provides a WEB host provides PHP and MySQL. You want to see the output, just create a file with ". php" as its extension, and write some valid code, upload, and browser access between the?> and the. But the same method does not apply to node. Of course, the Node hosts have many options, but they need more settings and command-line access, which is unpleasant for beginners. There is no doubt that PHP has won the match in this round.

Eighth round: Performance

The eighth round focuses on speed. While this often relies on experience and how much the development team is focused on, Craig notes the advantages of Node in some ways.

Bruno:

Mistakes abound. First, this article has a detailed discussion of performance, which excludes developer experience and the impact of application types on performance. If that article still doesn't make you understand how ignorant it is to talk about performance without context, let me talk about my point of view:

    • PHP is embedding a multithreaded server. This makes it possible to bypass the external server completely, but is not recommended for the time being. There are also some super fast servers (like Nginx) that make the whole process of starting PHP and distributing requests fast to be ignored.

    • PHP's native asynchronous (non-blocking I/O) support will be rolled out in the PHP7, and it is pointless to implement a similar pattern reactphp years ago.

    • The life cycle pattern of PHP single-request is the biggest burden. Indeed, if you simply pursue speed, it can still be easy to get around, not just through a similar approach as Memcached and Craig, but through a similar, Ajax approach. By the way--service-side JS application is also single-request by default. In addition-this single-request lifecycle is also an advantage, with every request to rebuild the application, avoid a lot of memory problems, empty the garbage memory, keep slim and clean. When was the last time you used a long running, memory-free Javascript application, regardless of the front-end or back end?

The discussion about performance is now and will be--draw (unless you are using Java, that Java must lose)

James:

Node is known for its high-performance, low-latency run-time environment, and it has found its own way to embed the code stacks of some of the top 500 companies. Because of its non-blocking I/O mechanism and Google Chrome V8 engine technology, Node has now become synonymous with "fast" and "scalable." There are a lot of stories on the web now, like how node lets companies get better performance improvements and provide developers with higher productivity. I'm glad that this round is a win, but I also understand that some people question this.

Nineth Round: Programmer Complex

Nineth round to see how much the average program staff feels about PHP and node, and finally he thinks that node wins.

Bruno:

You must have seen the wrong place, craig,php. The community is incredibly enthusiastic and lively, with more than 20 congresses and very exciting thematic discussions each year. This is the only way to complete the HHVM PHP7.

Also, what I'm trying to say is that I'm curious about which version of the Node's developers are working on (v0.12.5 is already writing), even after a 6-year show. It's immature and dangerous (oh, God, do you use an unstable technique that you intentionally let your business hang up with, plus, it ignores some of the old bugs in the OS that will lead some important developers to leave the language ecosystem.

Some negative experiences make me dislike Node, mainly because of NPM. The future may change, but now every time we use Node, I feel scared and disappointed. We all have our own preferences, but it's important to stay objective and choose the right tools to work with. But it is also important to allow others to try to make mistakes, because everyone is an afterthought. So don't listen to Craig, don't listen to Jim, don't listen to me. Try it boldly, see what you can use, find something that makes you feel good, and in the end, those that make you feel productive are the best, not the ones that save some load time.

James:

node is very hot, there is a lot of innovation in the field of node, although the passion is not objective, but very happy node won the bureau.

Tenth round: the future

In the tenth round, the prospect of two languages, based on both languages, seems to have a promising future at this stage, and Craig concludes that the result of the round is a draw.

Bruno:

Bruno had to hurry to write more articles about PHP and to maintain the amazing sitepoint PHP channel.

James:

James could not wait to return to his beloved JavaScript channel, but he left these points:

A draw is fair to this round. Node is a rising star, but if you want to shake PHP's throne, it will take a lot of effort.

Overall, if the hammer is your only tool, then every problem looks like a nail. Node is not perfect for every solution, and of course it's very reasonable not to use node at all. However, Node can do it and he can do it very well. It is entirely up to you to make a sensible decision to choose the best tool for your project.

Now that Bruno and James have made their point, what do you think of it?

Bruno Skvorc

The Croatian programmer Bruno has three master's degrees in computer science, English and literature. He is a PHP columnist for the SitePoint website, or a diffbot.com evangelist. He avoids the plague-like legacy code, picking a project that despite the latest technology, he is still a treadmill desk enthusiast and live board player, he has a blog: sometimes blogs.

James Hibbard

I am a web developer, currently living in the sunny northern part of Germany. I like to use JavaScript and Ruby programming, and you can often see me in SitePoint's JavaScript forum. I like running when I don't write code.



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.