SitePoint Smackdown:PHP与Node.js

The PHP vs Node gloves are on

The web is ever-changing technology landscape. Server-side developers have a bewildering choice of long-standing heavy-weights such as Java, C, and Perl to newer, web-focused languages such as Ruby, Clojure and Go. It rarely matters what you choose, presuming your application works.

网络是不断变化的技术格局。 服务器端开发人员可以选择长期困惑的Java,C和Perl等重量级人物,而选择诸如Ruby,Clojure和Go之类的面向Web的新型语言。 假定您的应用程序正常运行,那么选择什么都无关紧要。

But how do those new to web development make an informed choice?

但是,那些刚接触Web开发的人如何做出明智的选择?

I hope not to start a holy war, but I’m pitting two development disciplines against each other:

我希望不要发动一场圣战,但我将两个发展学科相互对抗:

  • PHP

    PHP

    PHP was created by Rasmus Lerdorf in 1994. It is processed by an interpreter normally installed as a module in a web server such as Apache or Nginx.

    PHP由Rasmus Lerdorf在1994年创建。它由通常作为模块安装在Web服务器(例如Apache或Nginx)中的解释器处理。

    PHP code can be intermingled with HTML. That’s not necessarily best-practice, but those new to the language can produce useful code very quickly. It contributed to the language’s popularity, and PHP is now used on more than 80% of the world’s web servers. It has been helped in no small part by WordPress — a PHP Content Management System which powers a quarter of all sites.

    PHP代码可以与HTML混合在一起。 这不一定是最佳实践,但是新接触该语言的人可以很快生成有用的代码。 它促进了该语言的流行,现在PHP已在全球80%以上的Web服务器上使用WordPress在很大程度上帮助了它—一个PHP内容管理系统, 为所有站点的四分之一提供支持

  • Node.js

    Node.js

    Node.js was created by Ryan Dahl in 2009. It uses Google’s

    Node.js由Ryan Dahl在2009年创建。它使用Google的

    V8 JavaScript engine, which also powers client-side code in the Chrome web browser. Unusually, the platform has built-in libraries to handle web requests and responses — you don’t need a separate web server or other dependencies.

    V8 JavaScript引擎 ,该引擎还支持Chrome网络浏览器中的客户端代码。 通常,该平台具有内置库来处理Web请求和响应-您不需要单独的Web服务器或其他依赖项。

    Node.js is relatively new but has been rapidly gaining traction. It’s used by companies including Microsoft, Yahoo, LinkedIn and PayPal.

    Node.js相对较新,但已Swift获得关注。 包括Microsoft,Yahoo,LinkedIn和PayPal在内的公司都在使用它。

C#,Java,Ruby,Python,Perl,Erlang,C ++,Go,Dart,Scala,Haskell等在哪里? (Where’s C#, Java, Ruby, Python, Perl, Erlang, C++, Go, Dart, Scala, Haskell, etc?)

An article which compared every option would be long. Would you read it? Do you expect a single developer to know them all? I’ve restricted this smackdown to PHP and Node.js because:

比较每个选项的文章会很长。 你会读吗? 您是否期望单个开发人员全部了解它们? 我将这种打击仅限于PHP和Node.js,因为:

  1. It’s a good comparison. They’re both open source, primarily aimed at web development and applicable to similar projects.

    这是一个很好的比较。 它们都是开源的,主要针对Web开发,并且适用于类似的项目。
  2. PHP is a long-established language but Node.js is a young upstart receiving increased attention. Should PHP developers believe the Node.js hype? Should they consider switching?

    PHP是一种历史悠久的语言,但是Node.js是一个新兴的新贵,受到越来越多的关注。 PHP开发人员应该相信Node.js的炒作吗? 他们应该考虑切换吗?
  3. I know and love the languages. I’ve been developing with PHP and JavaScript since the late 1990s, with a few years of Node.js experience. I’ve dabbled in other technologies, but couldn’t do them justice in this review.

    我知道并喜欢这些语言。 自1990年代后期以来,我一直在使用PHP和JavaScript进行开发,并且拥有几年的Node.js经验。 我涉猎其他技术,但是在这篇评论中不能说服他们。

Besides, it wouldn’t matter how many languages I compared. Someone, somewhere, would complain that I hadn’t included their favorite!

此外,我比较多少种语言都没关系。 某处某人会抱怨我没有包括他们的最爱!

关于SitePoint精简 (About SitePoint Smackdowns)

Developers spend many years honing their craft. Some have languages thrust upon them, but those who reach Ninja level usually make their own choice based on a host of factors. It’s subjective; you’ll promote and defend your technology decision.

开发人员花了很多年磨练自己的技巧。 有些语言会强加于他们,但是达到忍者级别的人通常会根据多种因素做出自己的选择。 这是主观的; 您将促进并捍卫您的技术决策。

That said, SitePoint Smackdowns are not “use whatever suits you, buddy” reviews. I will make recommendations based on my own experience, requirements and biases. You’ll agree with some points and disagree with others; that’s great — your comments will help others make an informed choice.

就是说,SitePoint Smackdowns并不是“使用任何适合您的东西,伙计”评论。 我将根据自己的经验,要求和偏见提出建议。 您会同意某些观点而不同意其他观点; 太好了-您的评论将帮助其他人做出明智的选择。

评估方法 (Evaluation Methodology)

PHP and Node.js are compared in the following ten rounds. Each bout considers a general development challenge which could be applied to any web technology. We won’t go too deep; few people will care about the relative merits of random number generators or array sorting algorithms.

在以下十轮中比较了PHP和Node.js。 每个回合都考虑到可以应用于任何Web技术的一般开发挑战。 我们不会太深入; 很少有人会关心随机数生成器或数组排序算法的相对优点。

The overall winner will be the technology which wins the most rounds. Ready? Let the battle commence …

总冠军将是获胜最多的技术。 准备? 让战斗开始……

第一轮:入门 (Round 1: Getting Started)

How quickly can you build a “Hello World” web page? In PHP:

您可以多快构建一个“ Hello World”网页? 在PHP中:

<?php
	echo 'Hello World!';
?>

The code can be placed in any file which is interpreted by the PHP engine — typically, one with a .php extension. Enter the URL which maps to that file in your browser and you’re done.

可以将代码放置在PHP引擎解释的任何文件中-通常是扩展名为.php 。 在浏览器中输入映射到该文件的URL,您就完成了。

Admittedly, this isn’t the whole story. The code will only run via a web server with PHP installed. (PHP has a built-in server, although it’s best to use something more robust). Most OSs provide server software such as IIS on Windows or Apache on Mac and Linux, although they need to be enabled and configured. It’s often simpler to use a pre-built set-up such as XAMPP or a virtual OS image (such as Vagrant). Even easier: upload your file to almost any web host.

诚然,这还不是全部。 该代码只能通过安装了PHP的Web服务器运行。 (PHP有一个内置服务器,尽管最好使用更强大的功能)。 大多数操作系统提供服务器软件,例如Windows上的IIS或Mac和Linux上的Apache,尽管需要启用和配置它们。 使用预构建的设置(例如XAMPP或虚拟OS映像(例如Vagrant ))通常更简单。 甚至更容易:将文件上传到几乎所有虚拟主机。

By comparison, installing Node.js is a breeze. You can either download the installer or use a package manager. So let’s create our web page in hello.js:

相比之下,安装Node.js轻而易举。 您可以下载安装程序使用软件包管理器 。 因此,让我们在hello.js创建我们的网页:

var http = require('http');
http.createServer(function (req, res) {
	res.writeHead(200, {'Content-Type': 'text/plain'});
	res.end('Hello World!');
}).listen(3000, '127.0.0.1');

You need to start the app from the terminal with node hello.js before you can visit http://127.0.0.1:3000/ in your browser. We’ve created a small web server in five lines of code and, amazing though that is, even those with strong client-side JavaScript experience would struggle to understand it.

您需要使用node hello.js从终端启动应用程序,然后才能在浏览器中访问http://127.0.0.1:3000/。 我们已经用五行代码创建了一个小型Web服务器,尽管令人惊奇的是,即使那些具有丰富的客户端JavaScript经验的人也很难理解它。

PHP is conceptually simpler and wins this round. Those who know a few PHP statements can write something useful. It has more software dependencies, but PHP concepts are less daunting to new developers.

PHP从概念上讲更简单,并且在本轮比赛中获胜。 那些了解一些PHP语句的人可以编写一些有用的东西。 它具有更多的软件依赖性,但PHP概念对新开发人员而言并不那么令人畏惧。

There’s a greater intellectual leap between knowing some JavaScript and coding Node.js apps. The development approach is different from most server-side technologies, and you need to understand fairly complex concepts such as closures and callback functions.

在了解一些JavaScript和对Node.js应用进行编码之间,存在一个更大的智力飞跃。 开发方法与大多数服务器端技术不同,您需要了解相当复杂的概念,例如闭包和回调函数。

第二轮:帮助与支持 (Round 2: Help and Support)

You won’t get far without some development assistance from the official documentation and resources such as courses, forums and StackOverflow. PHP wins this round easily; it has a great manual and twenty years’ worth of Q&As. Whatever you’re doing, someone will have encountered a similar issue before.

没有官方文档和资源(如课程论坛StackOverflow)的开发帮助,您将步履维艰PHP轻松赢得本轮比赛; 它具有出色的手册和长达20年的问答环节。 无论您做什么,以前都会有人遇到过类似的问题。

Node.js has good documentation but is younger and there is less help available. JavaScript has been around as long as PHP, but the majority of assistance relates to in-browser development. That rarely helps.

Node.js的文档很好,但还比较年轻,并且可用的帮助较少。 JavaScript的历史与PHP差不多,但是大多数帮助都与浏览器内部开发有关。 这很少有帮助。

第三轮:语言语法 (Round 3: Language Syntax)

Are statements and structures logical and easy to use?

语句和结构是否合理且易于使用?

Unlike some languages and frameworks, PHP doesn’t force you to work in a specific way and grows with you. You can start with a few multi-line programs, add functions, progress to simple PHP4-like objects and eventually code beautiful object-oriented MVC PHP5+ applications. Your code may be chaotic to start with, but it’ll work and evolve with your understanding.

与某些语言和框架不同,PHP不会强迫您以特定的方式工作,而是会与您一起成长。 您可以从一些多行程序开始,添加功能,进入简单的类似于PHP4的对象,并最终编写漂亮的面向对象的MVC PHP5 +应用程序。 您的代码一开始可能很混乱,但是随着您的理解,它会起作用并不断发展。

PHP syntax can change between versions, but backward compatibility is generally good. Unfortunately, this has led to a problem: PHP is a mess. For example, how do you count the number of characters in a string? Is it count? str_len? strlen? mb_strlen? There are hundreds of functions and they can be inconsistently named. Try writing a few lines of code without consulting the manual.

PHP语法可以在版本之间进行更改,但是向后兼容性通常很好。 不幸的是,这导致了一个问题: PHP是一团糟 。 例如,如何计算字符串中的字符数? count吗? str_lenstrlenmb_strlen ? 有数百种功能,它们的名称可能不一致。 尝试编写几行代码,而不参考手册。

JavaScript is comparatively concise, with a few dozen core statements. That said, the syntax attracts venom from developers because its prototypal object model seems familiar but isn’t. You’ll also find complaints about mathematical errors (0.1 + 0.2 != 0.3) and type conversion confusion ('4' + 2 == '42' and '4' - 2 == 2) — but these situations rarely cause problems, and all languages have quirks.

JavaScript比较简洁,有几十个核心语句。 就是说,该语法吸引了开发人员的注意,因为其原型对象模型看起来很熟悉,但并不熟悉。 您还会发现有关数学错误( 0.1 + 0.2 != 0.3 )和类型转换混乱( '4' + 2 == '42''4' - 2 == 2 )的抱怨-但是这些情况很少会引起问题,并且所有语言都有怪癖。

PHP has benefits, but I’m awarding round three to Node.js. The reasons include:

PHP有好处,但是我将第三轮授予Node.js。 原因包括:

  1. JavaScript remains the world’s most misunderstood language — but, once the concepts click, it makes other languages seem cumbersome.

    JavaScript仍然是世界上最容易被误解的语言 -但是,一旦概念被点击,它就会使其他语言显得笨拙。

  2. JavaScript code is terse compared to PHP. For example, you’ll no longer need to translate to/from JSON and — thankfully — UTF-8.

    与PHP相比,JavaScript代码更为简洁。 例如,您将不再需要从JSON和翻译成/ - 谢天谢地 - UTF-8。

  3. Full-stack developers can use JavaScript on the client and server. Your brain doesn’t need to switch modes.

    全栈开发人员可以在客户端和服务器上使用JavaScript。 您的大脑不需要切换模式。
  4. Understanding JavaScript makes you want to use it more. I couldn’t say the same for PHP.

    了解JavaScript使您想更多地使用它。 对于PHP,我无法说同样的话。

第四轮:开发工具 (Round 4: Development Tools)

Both technologies have a good range of editors, IDEs, debuggers, validators and other tools. I considered calling a draw but there’s one tool which gives Node.js an edge: npm — the Node Package Manager. npm allows you to install and manage dependencies, set configuration variables, define scripts and more.

两种技术都有大量的编辑器,IDE,调试器,验证器和其他工具。 我考虑过进行抽签,但是有一个工具可以使Node.js更具优势: npm-Node Package Manager 。 npm允许您安装和管理依赖项,设置配置变量,定义脚本等。

PHP’s Composer project was influenced by npm and is better in some respects. However, it’s not provided with PHP by default, has a smaller active repository and has made less of an impact within the community.

PHP的Composer项目受npm影响,并且在某些方面更好。 但是,默认情况下未随PHP一起提供它,具有一个较小的活动存储库,并且对社区的影响较小。

npm is partially responsible for the growth of build tools such as Grunt and Gulp which have revolutionized development. PHP developers will probably want/need to install Node.js at some point. The reverse isn’t true.

npm对诸如Grunt和Gulp之类的构建工具的发展负有部分责任,这已经彻底改变了开发。 PHP开发人员可能会希望/需要在某个时候安装Node.js。 反之则不正确。

第五回合:环境 (Round 5: Environments)

Where can the technologies be used and deployed? Which platforms and ecosystems are supported? Web developers often need to create applications which aren’t strictly for the web, e.g. build tools, migration tools, database conversion scripts, etc.

这些技术可以在哪里使用和部署? 支持哪些平台和生态系统? Web开发人员经常需要创建不严格用于Web的应用程序,例如构建工具,迁移工具,数据库转换脚本等。

There are ways to use PHP for desktop and command-line app development. You won’t use them. At heart, PHP is a server-side development technology. It’s good at that job but is rarely stretched beyond those boundaries.

有多种使用PHP进行桌面和命令行应用程序开发的方法。 您不会使用它们。 从本质上讲,PHP是一种服务器端开发技术。 擅长这项工作,但很少超出这些范围。

A few years ago, JavaScript would have been considered more restrictive. There were a few fringe technologies but its main place was in the browser. Node.js has changed that perception and there has been an explosion of JavaScript projects. You can use JavaScript everywhere — in the browser, on the server, terminal, desktop and even embedded systems. Node.js has made JavaScript ubiquitous.

几年前,JavaScript被认为更具限制性。 有一些附带技术,但它的主要位置是在浏览器中。 Node.js改变了这种看法,并且JavaScript项目激增。 您可以在浏览器,服务器,终端,台式机甚至嵌入式系统中的任何地方使用JavaScript。 Node.js使JavaScript无处不在。

第六轮:整合 (Round 6: Integration)

Development technologies are restricted unless they can integrate with databases and drivers. PHP is strong in this area. It’s been around for many years and its extensions system allow direct communication with a host of popular and obscure APIs.

除非开发技术可以与数据库和驱动程序集成,否则它们是受限制的。 PHP在这方面很强大。 它已经存在了很多年,其扩展系统允许与许多流行且晦涩的API直接通信。

Node.js is catching up fast, but you may struggle to find mature integration components for older, less-popular technologies.

Node.js的追赶速度很快,但是您可能很难为较老的,人气较低的技术找到成熟的集成组件。

第七回合:托管和部署 (Round 7: Hosting and Deployment)

How easy is deploying your shiny new app to a live web server? It’s another clear win for PHP. Contact a random selection of web hosting companies and you’ll discover the majority offer PHP support. You’ll probably get MySQL thrown in for a bargain price. PHP is considerably easier to sandbox and more risky extensions can be disabled.

将闪亮的新应用程序部署到实时Web服务器有多容易? 这是PHP的另一个明显胜利。 联系随机选择的网络托管公司,您将发现大多数提供PHP支持。 您可能会以讨价还价的价格购买MySQL。 PHP易于沙盒化,可以禁用更具风险的扩展。

Node.js is a different beast and server-side apps run permanently. You’ll need a real/virtual/cloud or specialist server environment, ideally with root SSH access. That’s a step too far for some hosts, especially on shared hosting where you could bring down the whole system.

Node.js与众不同,服务器端应用程序永久运行。 您将需要一个真实/虚拟/云或专业服务器环境,最好具有root SSH访问权限。 对于某些主机而言,这是太过分了,特别是在共享主机上,您可以在其中关闭整个系统。

Node.js hosting will become simpler, but I doubt it’ll ever match the ease of FTP’ing a few PHP files.

Node.js托管将变得更加简单,但是我怀疑它能否与FTP分发一些PHP文件的便捷性相提并论。

第八回合:表现 (Round 8: Performance)

PHP is no slouch and there are projects and options which make it faster. Even the most demanding PHP developer rarely worries about speed but Node.js performance is generally better. Of course, performance is largely a consequence of the experience and care taken by the development team but Node.js has several advantages…

PHP一点也不懒,并且有一些项目和选项可以使它更快。 即使是最苛刻PHP开发人员也很少担心速度,但是Node.js的性能通常会更好。 当然,性能很大程度上取决于开发团队的经验和谨慎,但是Node.js具有多个优势……

更少的依赖 (Fewer Dependencies)

All requests to a PHP application must be routed via a web server which starts the PHP interpreter which runs the code. Node.js doesn’t need so many dependencies and, while you’ll almost certainly use a server framework such as Express, it’s lightweight and forms part of your application.

对PHP应用程序的所有请求都必须通过网络服务器路由,该服务器启动运行代码PHP解释器。 Node.js不需要那么多的依赖关系,尽管您几乎可以肯定会使用诸如Express之类的服务器框架,但它是轻量级的,并且构成了应用程序的一部分。

较小,更快的口译员 (A Smaller, Faster Interpreter)

Node.js is smaller and nimbler than the PHP interpreter. It’s less encumbered by legacy language support and Google has made a huge investment in V8 performance.

Node.js比PHP解释器更小巧。 它不受传统语言支持的困扰,并且Google在V8性能上进行了巨额投资。

申请永久存在 (Applications are Permanently On)

PHP follows the typical client-server model. Every page request initiates your application; you load configuration parameters, connect to a database, fetch information and render HTML. A Node.js app runs permanently and it need only initialize once. For example, you could create a single database connection object which is reused by everyone during every request. Admittedly, there are ways to implement this type of behavior in PHP using systems such as Memcached but it’s not a standard feature of the language.

PHP遵循典型的客户端-服务器模型。 每个页面请求都会启动您的应用程序; 您可以加载配置参数,连接到数据库,获取信息并呈现HTML。 Node.js应用程序将永久运行,并且只需初始化一次。 例如,您可以创建一个数据库连接对象,每个请求期间每个人都可以重复使用该对象。 诚然,有很多方法可以使用诸如Memcached之类的系统在PHP中实现这种行为,但这不是该语言的标准功能。

事件驱动的非阻塞I / O (An Event-driven, Non-Blocking I/O)

PHP and most other server-side languages use an obvious blocking execution model. When you issue a command such as fetching information from a database, that command will complete execution before progressing to the next statement. Node.js doesn’t (normally) wait. Instead, you provide a callback function which is executed once the action is complete, e.g.

PHP和大多数其他服务器端语言使用明显的阻塞执行模型。 当发出诸如从数据库中获取信息之类的命令时,该命令将在执行下一条语句之前完成执行。 Node.js不会(通常)等待。 取而代之的是,您提供一个回调函数,该动作一旦完成即会执行,例如

// fetch records from a NoSQL database
DB.collection('test').find({}).toArray(process);
console.log('finished');

// process database information
function process(err, recs) {
	if (!err) {
		console.log(recs.length + ' records returned');
	}
}

In this example, the console will output ‘finished’ before ‘N records returned’ because the process function is called when all the data has been retrieved. In other words, the interpreter is freed to do other work while other processes are busy.

在此示例中,控制台将在“返回N条记录”之前输出“完成”,因为在检索到所有数据后将调用process函数。 换句话说,在其他进程繁忙时,解释器可以自由地执行其他工作。

Note that situations are complex and there are caveats:

请注意,情况很复杂,并且有一些警告:

  • Node.js/JavaScript runs on a single thread while most web servers are multi-threaded and handle requests concurrently.

    Node.js / JavaScript在单个线程上运行,而大多数Web服务器是多线程的,并且可以同时处理请求。
  • Long-running JavaScript processes for one user prevent code running for all other users unless you split tasks or use Web Workers.

    除非您拆分任务或使用Web Workers,否则一个用户长时间运行JavaScript进程会阻止所有其他用户运行代码。

  • Benchmarking is subjective and flawed; you’ll find examples where Node.js beats PHP and counter examples where PHP beats Node.js. Developers are adept at proving whatever they believe!

    标杆管理是主观的和有缺陷的; 您将找到Node.js胜过PHP的示例,以及PHP胜过Node.js的示例。 开发人员善于证明他们所相信的一切!
  • Writing asynchronous event-driven code is complex and incurs its own challenges.

    编写异步事件驱动的代码很复杂,并带来了自己的挑战。

I can only go from experience: my Node.js applications are noticeably faster than PHP equivalents. Yours may not be but you’ll never know until you try.

我只能从经验中走出来:我的Node.js应用程序明显比同等PHP快。 您可能不是,但是直到尝试为止,您永远不会知道。

第9回合:程序员的激情 (Round 9: Programmer Passion)

This may be stretching the “general web development challenge” objective but it’s important. It doesn’t matter whether a technology is good or bad if you dread writing code every day.

这可能扩展了“一般Web开发挑战”的目标,但这很重要。 如果您每天都不怕编写代码,那么技术的好坏并不重要。

It’s a little difficult to make comparisons but relatively few PHP developers are passionate about the language. When was the last time you read a PHP article or saw a presentation which captivated the audience? Perhaps everything has been said? Perhaps there’s less exposure? Perhaps I’m not looking in the right places? There are some nice features arriving in PHP7 but the technology has been treading water for a few years. That said, few PHP developers berate the language.

进行比较有点困难,但是很少有PHP开发人员对这种语言充满热情。 您上次阅读PHP文章或看到一个吸引观众的演示是什么时候? 也许一切都说了吗? 也许曝光更少? 也许我找的地方不对? PHP7提供了一些不错的功能,但是该技术已经投入了数年。 话虽如此,很少有PHP开发人员对这种语言be之以鼻。

JavaScript splits the community. There are those who love it and those who hate it; few developers sit on the fence. However, response to Node.js has been largely positive and the technology is riding the crest of a wave. This is partly because it’s new and the praise may not last but, for now, Node.js wins this round.

JavaScript分裂了社区。 有些人喜欢它,有些人讨厌它。 很少有开发商坐在栅栏上。 但是,对Node.js的响应在很大程度上是积极的,并且该技术正处于浪潮中。 部分原因是它是新的,赞誉可能不会持久,但是就目前而言, Node.js赢得了这一轮。

第十回合:未来 (Round 10: The Future)

It doesn’t particularly matter which server-side language you use; it will continue to work even if the project is abandoned (yay ColdFusion!) Usage has possibly plateaued but many continue to use PHP. It’s a safe bet and support looks assured for another twenty years.

使用哪种服务器端语言并不特别重要; 即使该项目被放弃(它是ColdFusion!),它也将继续起作用。使用率可能已达到稳定水平,但是许多人继续使用PHP。 这是一个安全的赌注,并且可以保证再获得二十年的支持。

The ascent of Node.js has been rapid. It offers a modern development approach, uses the same syntax as client-side development and supports revolutionary HTML5 features such as web sockets and server-sent events. There has been some confusion regarding forks of the language but usage continues to grow at an exponential rate.

Node.js的发展非常Swift。 它提供了一种现代的开发方法,使用与客户端开发相同的语法,并支持革命性HTML5功能,例如Web套接字和服务器发送的事件。 关于语言的分支一直存在一些困惑,但使用率仍以指数级增长。

Node.js will inevitably eat into PHP’s market share but I doubt it will overtake. Both technologies have a bright future. I declare this round a draw.

Node.js不可避免地会吞噬PHP的市场份额,但我怀疑它会超过PHP。 两种技术都有光明的前景。 我宣布本轮平局。

总冠军 (The Overall Winner)

The final score: five rounds to Node.js, four to PHP and one draw. The result was closer than I expected and could have gone either way.

最终得分:五轮进入Node.js ,四轮进入PHP ,一局平局。 结果比我预期的要近,并且可能以任何一种方式发生。

Node.js has a steep learning curve and isn’t ideal for novice developers but it wins this smackdown. Just. If you’re a competent JavaScript programmer who loves the language, Node.js doesn’t disappoint. It feels fresher and offers a liberating web development experience — you won’t miss PHP.

Node.js具有陡峭的学习曲线,对于新手开发人员而言并不理想,但它赢得了这一赞誉。 只是 。 如果您是一位精通JavaScript的合格JavaScript程序员,那么Node.js不会令人失望。 感觉更新鲜,并提供了解放性的Web开发体验- 您将不会错过PHP

But don’t discount it. PHP is alive and there’s little reason to jump on the Node.js bandwagon because it looks faster, newer or trendier. PHP is easier to learn yet supports proficient professional programming techniques. Assistance is everywhere and deployment is simple. Even die-hard Node.js developers should consider PHP for simpler websites and apps.

但不要打折。 PHP仍然存在,并且没有理由跳上Node.js潮流,因为它看上去更快,更新或更流行。 PHP易于学习,但支持熟练的专业编程技术。 帮助无处不在,部署简单。 即使是顽固的Node.js开发人员,也应该考虑将PHP用于更简单的网站和应用程序。

My advice: assess the options and and pick a language based on your requirements. That’s far more practical than relying on ‘vs’ articles like this!

我的建议: 评估选项并根据您的要求选择一种语言 。 这比依赖像这样的“ vs”文章要实际得多!



Do you agree with Craig’s conclusion? Was the comparison fair? Were the rounds rigged? Don’t get angry — get writing …

您是否同意克雷格的结论? 比较公平吗? 是否进行了回合? 不要生气-开始写作...

You might also be interested in our Right of Reply response to this article by SitePoint’s PHP and JS editors!

您可能还对SitePointPHP和JS编辑器对本文的答复权感兴趣!

翻译自: https://www.sitepoint.com/sitepoint-smackdown-php-vs-node-js/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值