PHP vs Nodejs: An epic campaign about developer preferences

Source: Internet
Author: User
Tags php language drupal

The whole story is just like the classic plot of Hollywood blockbusters: two of former friends are now parted, even forced into a life-and-death struggle. The beginning of the disagreement was not serious, but an old friend had a little interest in another partner's long-held but not-so-silent business areas. In the real version of this programming language duel in the big movie, node. JS became the fuse that became a good brother, and this led to a close, equal battle: PHP and JavaScript, the two sides once together to rule the entire Internet world, But now it's killing the other person to fight for the support of the developers.

Thinking back, the partnership is always simple and pure. While JavaScript was responsible for dealing with the details of the browser, PHP managed all the server-side tasks that existed between Port 80 and MySQL. At that time, the two sides maintained a cheerful cooperative mentality, and continuously for the Internet's various key components to provide support. Whether it's WordPress, Drupal or Facebook, without PHP, people can't stay on the web for almost a minute.

Yet a clever technician has discovered a startling secret: JavaScript is also fully capable of running on the server. Almost overnight, we don't seem to have the power of PHP to build next-generation server stacks. In one language alone, we have been able to build node. js and other types of frameworks that run on the client. "JavaScript everywhere" even becomes part of the developer's work faith.

Of course, the end of the story has not been finalized. For every developer who preaches the advanced nature of node. JS and the convenience of JavaScript, there are always those who are against themselves-they prefer the deep code base of PHP and the long-term stability of the actual performance. Could the old-fashioned master rout the challenger on the server-side home of his years of dominance? Will JavaScript ruthlessly overthrow its old friends and complete its unified ambitions? Please pick up the popcorn bucket and coke, together to watch this wonderful tongshicaoge show.

PHP wins: Mix code with content

In the process of the input of course, you want to be able to convert their ideas directly into the text content of the site, but also to add a branch of the process, a part of the If-then statement to ensure that the site has a beautiful visual effect, depending on some parameters in the URL. Or, we want to be able to mix text or data with a single database. With the help of PHP, you just have to open the Magic PHP tag and start writing code in seconds. Yes, you don't need any templates--because everything already belongs to the template! Without the use of extra files or complex architectures, the power of programmable logic is at our fingertips, waiting for you to dispatch.

node. JS Wins: Focus Division

Mixing code with content like a magical crutch, although it starts to guide the user well, it often becomes a heavy burden in the end. True, it's really interesting to mix code with HTML-at least for the first few experiences. But a lot of our code base becomes a bunch of mess that are logically intertwined. A real programmer adds a structure to it and divides the modifier layer from the logical layer. It is clear that novice developers will be able to get a clearer picture of the project and be more likely to perform subsequent maintenance work. The frameworks that run on node. JS are built by a bunch of programmers who know that life will be better when models, views, and controllers are clearly divided.

PHP wins: A deep code base

The entire web world is flooded with PHP code. The various mainstream platforms used to build the site (including WordPress, Drupal, Joomla, etc.) are written in the PHP language. In addition to these platforms, most of the related plug-ins also exist in the form of open source code. All in all, the PHP code is handy, waiting for you to download it, modify it, and use it flexibly as needed.

Node wins: The new generation code means modern functionality

Admittedly, thousands of open source PHP files do help make project development easier, but many of the eight-year-old WordPress plugins are waiting and looking for developers to download and use them. Who would like to spend hours, days, or even weeks debugging code that hasn't been updated for years? At least I don't want to. The node. JS Plugin is not only younger, but also enjoys the convenience of the latest architecture solution. The developers who develop this part of the code are well aware that modern web applications should introduce more intelligent elements into the client.

PHP wins: Ease of access (more or less)

The PHP language does not have much to say in its use: Several variables plus the basic functions of strings and numbers are everything. This is a very focused solution that users expect to use only to move data from port 80 to the database and back end. PHP does not have much ambition and it is the bounden duty to do the job well. Modern databases are a kind of miraculous tool, so we can give all kinds of heavy load to it to handle. PHP is a moderately complex approach, and there is no need to deliberately make it difficult to use.

Node wins: Closure complexity, etc.

Some of the little awkward uses of JavaScript may be maddening for some developers, but overall it is a modern programming language that contains a large number of modern syntax plus a series of practical features that are represented by closures. You can easily reconfigure and extend it so that powerful libraries like jquery can be made possible. We don't have to be upset about features like objects. Why do you have to fight with yourself?

PHP wins: No client apps required

Everyone says that if you can use the same language on your browser and server, the actual effect is definitely the best. But wouldn't the result be better if we didn't have to use any language in the browser at all? What if we can implement data output directly in HTML format? The browser is able to accept this data directly and does not have to endure the various types of trouble and failures that a JavaScript thread attempts to create pages on a browser with dozens of Web service calls. Pure HTML tends to work better than other forms, and PHP is optimized for such creation tasks. Why bother to introduce JavaScript into the browser? Build everything on the server and try to avoid putting too much effort into small browsers on small phones, which is the right solution.

Node wins: Service calls are more streamlined than bloated PHP HTML calls

Although Ajax often plugs a large number of moving parts into HTML 5 Web applications, they are really cool-and very effective. Once the JavaScript code enters the browser cache, there is only new data left to transfer between network lines. Here we don't have to face tons of HTML tags, and we don't have to download the entire page content repeatedly. Only the data will change. If you are willing to take the time to create a sophisticated Web application, it will definitely give you the ideal return. node. JS is deeply optimized for the data delivery mechanism, and the data needs to be provided only to Web services. If everyone's application is complex and full of data, then node. JS will undoubtedly build a good foundation for the effective delivery of information.

PHP wins: SQL

PHP's design thinking itself takes into account the coexistence and collaboration needs of MySQL and its many variants, such as mariadb--. If MySQL isn't enough to meet everyone's real needs, there's more to choose from, as well as other excellent SQL databases from Oracle and Microsoft. Our code can be transformed into a query instruction after a simple launch. The vast SQL world is endless, and its territory is still expanding. A significant portion of the most stable and well-developed code will interface with the SQL database, which means that all these powerful capabilities will eventually be easily integrated into the PHP project. Perhaps the entire ecosystem is not yet a perfect and harmonious family, but its sizeable size is undeniable.

node. JS wins: JSON

If you have to access SQL, then node. JS also provides a library to do the job. But in addition to this, node. JS is also interoperable with JSON, a common solution that interacts with many of the latest NoSQL databases. This is not to say that there is no way to get a JSON library in our own PHP stack, but when using JSON with JavaScript, it is often a simple and convenient task-handling process. In this way, we can guarantee to use the same syntax from the browser to the Web server to the database, where the colon and parentheses are used exactly the same way. This will help you save development time, significantly reducing the frustration of code writing.

PHP Wins: Encoding speed

For most developers, writing Web applications with PHP tends to get a more efficient coding experience: no need for a compiler, no deployment, no need to mention jar files or preprocessing mechanisms-just take advantage of your favorite editor and some PHP files in the directory, and your development will work. Your actual development process may be different, but speaking of the quick-fix project of the Divine Weapon, PHP in this fight is definitely the one.

node. JS wins: Original speed

Writing JavaScript code is a bit more difficult from the point of view of the curly braces and parentheses in the code itself, but after the development effort, the node. JS code is running incredibly fast. The introduction of the callback mechanism is a genius, because it can greatly save us time in dealing with different threads. The core of the code is well-built and specifically designed to achieve our actual needs. Isn't that what every developer is dreaming of?

English: http://www.infoworld.com/article/2866712/php/php-vs-node-js-an-epic-battle-for-developer-mind-share.html

The above describes the PHP PvP Nodejs: An epic campaign about developer preferences, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.

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