PHP and node. JS 10 Comparison Challenge _php Tutorial

Source: Internet
Author: User
Tags php and mysql install node web hosting

10 comparison challenges for PHP and node. js


In the recent sitepoint of PHP vs node. js SmackDown, Craig Buckler compares the two languages on how to respond to 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 PHP developers) and a JavaScript developer at James Hibbard SitePoint to comment on each round.

Here are their detailed views ...

First round: Start

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

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

Bruno:

PHP won the "start" round purely because more hosts supported the language and thus began very simple. It's easy to use without having to do anything extra. If more hosts ignore file uploads directly using the Node command line and use a simple "reload app" key on the control Panel, the two will be the same. However, in terms of the actual syntax for displaying things on the screen, PHP is simpler-especially for those who have no programming experience.

James:

When I was developing on a local machine, I didn't see a big difference between the two. To run PHP scripts on your browser, you need to install some server software; To run the node script, you need to install node, and it's best to install a Web framework like Express. However, as Craig says, PHP is "conceptually simpler". Node's entry threshold is even higher. There is no dispute over 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 for now, help will be less. But when node matures, that's not a problem.

Third round: Grammar

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

Bruno:

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

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

Bullet 4 (Understanding JS will make you want to use it more) this is in a way I agree. I use JS and PHP for many years in my work, I use JS for a long time, but I like very little about it-even though that is purely personal inclination.

James:

I love JavaScript. I know it has its quirks, and I know for some reason that ECMAScript 2015 will modify some and bring some exciting new features to the language. JavaScript is powerful and flexible, and can adapt to many different styles of programming. In contrast with PHP, I enjoy using JavaScript. Nodenode.js) is one of them.

Fourth round: Development tools

Round 4: Consider the development tools used by the two technologies, Node because of the development tool NPM, so notch above.

Bruno:

While the developer was initially inspired by NPM, leaps and bounds are now more comfortable than NPM, and if you install two versions of the same library on your computer, leaps and bounds will not crash your system. and leaps and bounds allow designers to use recursive thinking relative to NPM, and recursive thinking is so important that when developers are ready to start building a package manager, this is the first thing to consider.

NPM also has a fatal disadvantage, I call it "developer collaboration friendly", NPM does not do this very well, for NPM only developers themselves can understand what they write. Finally, NPM is not well-compatible with Vagrant, which directly hinders 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 many years, and it's not a small problem because it makes the software virtually impossible to use on Windows. Of course, PHP also has a lot of stupid mistakes, but these errors do not have problems with your system.

It is true that PHP does not come with a compiler, but I do not think it should. This convenience should not be done by a package manager or a standalone application. If one day someone developed a good package manager for Node, it would be extremely difficult to replace it with the existing compiler. Make it relatively independent, people can easily switch. In addition, installing it requires only one line of code to be entered on the terminal, or a setup program to download.
It is obvious that the compiler mentioned in the book has a very small effect. Since the completion of PHP development, the compiler has affected every new PHP developer, some of whom have to add it to the existing process. Just because there are many PHP users before the compiler exists, it does not indicate that it is less useful. In fact, it has had a huge impact since it was created. What some people call "little impact on the community" has no factual basis at all.
Now, I can't argue that most PHP developers want to install Node, which is really true. Sadly, a lot of good tools are first developed based on Node, but I still want to be like the Node-free development environment and can also be used to develop bowerphp.

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 between global and local packages in contrast, some languages like Ruby, whose standards require you 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 the beta version of the 3rd edition. It solves a number of problems that Bruno mentions, such as nested 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 some occasions. The reverse is not true.

Fifth round: Environment

The 5th round is about the availability and deployment of technology, and what platforms and ecosystems are supported. Craig is not very clear about this, but it seems to be more in favor of Node.

Bruno:

Craig says he has compared PHP and Node Web-related advantages to common web development issues, and then says JS is used everywhere. First, let's compare node. js, not JS itself, and secondly, we compare the circumstances under which two languages can 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 they're doing.

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

James:

Craig and I agreed once again. Some of the features that make node. js so popular, extensible, closely linked to JSON, and low in resource usage, makes it suitable for many other types of applications, such as powerful IoT devices. I think, who doesn't like robots?

Node makes the project a boost, such as nw.js a Chromium and node. JS-based app, which allows you to write local apps on HTML and JavaScript. How exciting!

Sixth round: Integration

6th round Let's take a look at the integration of database and drive, PHP wins mainly because it is older.

Bruno:

The integration is actually a draw, PHP has an age advantage 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 hasn't been available for years.

James:

I certainly agree with this view, which seems to blur the word, and I like the example: "Outdated, more popular technology". And that's a good point. Node has a big advantage-it natively supports JSON. JSON is perhaps the most important data transfer format in the Web, and it is also a common structure for the latest NoSQL databases. Using JSON in a JavaScript program is easy, meaning that when you work with Node, the data can be transferred very concisely without the need for a 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's easy to deploy a new app to a WEB server, and in Craig's opinion, PHP is obviously the winner.

Bruno:

Bruno remained silent once more.

James:

This is the area where Node needs to work to improve. Each company that provides WEB hosting provides PHP and MySQL. You want to see the output, just create a file with ". php" for the extension, write some valid code between them, upload it, and access it in a browser. But the same approach does not apply to node. Of course, Node hosts have many options, but they require more setup 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:

Errors abound. First, this article has a detailed discussion of performance, which excludes the developer experience and the impact of the application type on performance. If that article still doesn't make you understand how foolish it is to throw aside the context, let me turn to my point of view:

    • PHP is embedding a multithreaded server. This makes it possible to completely bypass external servers, but is not recommended for the time being. In addition, there are some super-fast servers like Nginx, they make the entire start of PHP, the process of distributing requests to be negligible.

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

    • PHP Single-request life cycle mode is the biggest burden. Indeed, if you simply pursue speed, but this one can still be easily bypassed, not just through Memcached and Craig's similar approach, but through a similar, Ajax approach. By the way--the service-side JS application is also single-request by default. In addition-this single-request life cycle is also an advantage, each request to rebuild the application, to avoid a lot of memory problems, emptying the garbage memory, keep slim and clean. When was the last time you used a stable, long-running, memory-free Javascript application, regardless of front end or back end?

The discussion of performance is now, and will be later--a draw unless you're using Java, that Java must lose.

James:

Node is known for its high-performance, low-latency runtime environment, and it has found its own way to embed the code stacks of some of the top 500 companies. Because of its nonblocking I/O mechanism and Google Chrome V8 engine technology, Node is now synonymous with "fast" and "extensible." There are a lot of stories online now, like node how to get a better performance boost for the company and more productivity for developers. I'm happy that this round of node wins, but I also understand that some people question this.

Nineth Round: Programmer Complex

In the Nineth round, I saw how much Craig felt about how the general handlers had feelings for PHP and node, and he finally thought that node was winning.

Bruno:

You must have seen the wrong place, the craig,php community is incredibly enthusiastic and active, with more than 20 conferences and very exciting themes to discuss every year. This is the only way to complete the HHVM PHP7.

In addition, I would like to say that I am very curious about Node developers who use the original version of the work v0.12.5 has begun to write, even after 6 years of the must show. It's immature and dangerous. Oh, you're using an unstable technology, you're deliberately letting your business hang up, plus, it ignores some of the older bugs in the operating system that will cause some important developers to leave the language's ecosystem.

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

James:

node is very hot, there are many innovations in node's field, although the passion is not objective, but it is very happy that node won the game.

Tenth round: the future

The tenth round looks at the outlook for both languages, and, based on both languages, seems to have a promising future at this stage, and Craig concludes that the result is a draw.

Bruno:

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

James:

James couldn't wait to get back to his beloved JavaScript channel, but he left these points:

The draw is fair for this round. Node is a rising star, but if you want to shake the throne of PHP, he will have to pay a lot of effort.

In general, if the hammer is your only tool, then every question looks like a nail. Node doesn't fit perfectly in every scenario, but it's also very reasonable to not use node very often. However, Node can do that and he can do it very well. It's 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 this problem?

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 development evangelist. He avoids the legacy code like the plague, the selection project is despite the use of the latest technology, he is also a treadmill desk enthusiast and live board player, he has a blog: sometimes blogs.

James Hibbard

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

http://www.bkjia.com/PHPjc/1043400.html www.bkjia.com true http://www.bkjia.com/PHPjc/1043400.html techarticle 10 comparison Challenges for PHP and node. JS in the recent sitepoint of PHP vs node. js SmackDown, Craig Buckler compares the two languages with a series of 10 challenges ...

  • 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.