热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

phphhvm_PHP6中的HHVM与ZendEngine

phphhvmThefabledPHP6islongoverdue.Thisunicornofthewebdevworldhasbeen“coming”fordecadesnow,

php hhvm

alt

The fabled PHP 6 is long overdue. This unicorn of the web dev world has been “coming” for decades now, and it’s still not clear whether or not it’s actually something that’s going to happen in this decade, or just an idea, a fantasy of the PHP userbase. Minor versions like 5.4 > 5.5 and 5.5 > 5.6 bring so many new features these days anyway, we often see them as major versions.

传说中PHP 6早该发布了。 这个Web开发界的独角兽已经“出现”了几十年了,目前尚不清楚这是否是这十年中将要发生的事情,或者只是一个想法,一个PHP用户群的幻想。 无论如何,次要版本5.4> 5.5和5.5> 5.6如今都带来了许多新功能 ,我们经常将它们视为主要版本。

My own personal fantasy for v6 is function naming consistency, a total break of backwards compatibility with PHP <6 in terms of global namespace pollution, and a full rewrite of all data types to classes much like in Scala or Dart, but hey, we all have our wild dreams.

我对v6的个人幻想是函数命名一致性&#xff0c;就全局命名空间污染而言完全中断了与PHP <6的向后兼容性&#xff0c;并将所有数据类型完全重写为类似于Scala或Dart的类&#xff0c;但是&#xff0c;嘿&#xff0c;我们都有我们疯狂的梦想。

For a great article on the unfortunate fate of PHP 6, please see here – and make sure you don’t skip the comments. There are some valuable lessons about the attitudes of core PHP devs to be learned there.

要获得有关PHP 6不幸命运的精彩文章&#xff0c;请在此处查看 -并确保不要跳过注释。 关于核心PHP开发人员的态度&#xff0c;这里有一些有价值的经验教训。

前提 (The premise)

Not many people know this, but http://www.phpclasses.org has some interesting, if very awkward podcasts rather often. It’s sometimes difficult to weed out the useful information from these talks, but Manuel’s contents list usually helps. If you’re curious about changes in PHP and keeping up with the latest news, why not fire it up while exercising, coding, cooking or whatever else? In the latest edition between Manuel Lemos and César Rodas, an interesting topic arose among others – Facebook’s HHVM replacing Zend Engine in PHP 6.

没有多少人知道这一点&#xff0c;但是http://www.phpclasses.org经常会播出一些有趣的(即使很尴尬的)播客。 有时很难从这些谈话中剔除有用的信息&#xff0c;但是曼努埃尔的内容清单通常会有所帮助。 如果您对PHP的更改感到好奇并紧跟最新消息&#xff0c;为什么不在锻炼&#xff0c;编码&#xff0c;烹饪或其他任何事情时就将其启动&#xff1f; 在Manuel Lemos和CésarRodas之间的最新版本中 &#xff0c;出现了一个有趣的话题– Facebook的HHVM取代了PHP 6中的Zend Engine。

While this was purely speculation on the part of the participants, and whether or not you believe in PHP 6, you have to admit it’s an interesting notion. As we’ve seen in the HHVM article, and on the HHVM blog, HHVM has been making strides in becoming compatible with most of the popular libraries, CMS, and frameworks out there. The team is doing what it can to improve performance as much as possible while keeping it compatible with existing codebases for various products. Let’s entertain the possibility of HHVM replacing ZE in PHP 6 and look at the pros and cons.

尽管这纯粹是参与者的猜测&#xff0c;以及您是否相信PHP 6&#xff0c;但您必须承认这是一个有趣的概念。 正如我们在HHVM文章和HHVM博客中所看到的那样&#xff0c;HHVM在与大多数流行的库&#xff0c;CMS和框架兼容方面取得了长足的进步。 该团队正在尽最大努力提高性能&#xff0c;同时使其与各种产品的现有代码库兼容。 让我们来探讨一下HHVM在PHP 6中替换ZE的可能性&#xff0c;并探讨其优缺点。

优点 (The pros)

Obviously, performance. HHVM is leaps and bounds faster than vanilla PHP, even with the default built in OpCache in 5.5. It uses fewer resources to do things faster. One can’t not see the advantages of this – consider, if you will, just the savings on cloud deployment bills. Fewer CPU and RAM usage means fewer instance hours.

显然&#xff0c;性能。 即使使用5.5中内置的默认存储&#xff0c;HHVM的速度也比普通PHP快得多。 它使用更少的资源来更快地处理事务。 谁也看不到这样做的好处–如果可以的话&#xff0c;只需考虑节省云部署费用即可。 更少的CPU和RAM使用量意味着更少的实例时间。

The next advantage is HHVM being backed by Facebook. Facebook uses HHVM to deploy their own PHP code, so they need to make sure it’s as efficient as possible. A 1% CPU spike means tens of thousands of dollars in expenses for them, so it’s only natural they’d rather throw that money at the HHVM team to make sure it never happens. As a result, HHVM is being developed by people far more experienced and focused – especially in today’s high-concurrency high-traffic world – than the actual core developers of Zend Engine and PHP. As an example, consider the fact that Facebook had generators in PHP three years before they made it into the mainstream PHP release.

下一个优势是Facebook支持HHVM。 Facebook使用HHVM部署自己PHP代码&#xff0c;因此他们需要确保它尽可能高效。 1&#xff05;的CPU高峰对他们来说意味着数万美元的支出&#xff0c;因此&#xff0c;他们自然愿意将这笔钱扔给HHVM团队以确保永远不会发生&#xff0c;这是很自然的。 因此&#xff0c;与Zend Engine和PHP的实际核心开发人员相比&#xff0c;HHVM的开发人员更为经验丰富且专注(尤其是在当今高并发&#xff0c;高流量的世界中)。 例如&#xff0c;考虑一下Facebook在使用PHP生成器三年后才成为主流PHP版本这一事实。

A further advantage is the ability to statically type in the most recent version of HHVM, via their internally developed Hack “language”. Hack is a derivate of PHP, but supports static typing. You start files you want to type check before compilation with instead of , and the compiler does the rest. A more detailed article on Hack is in the works and will be published soon. This approach further increases the quality of compilation, making native code that much more efficient, and HHVM’s PHP that much faster.

另一个优势是能够通过其内部开发的Hack“语言”静态键入最新版本的HHVM。 Hack是PHP的派生产品&#xff0c;但支持静态类型。 您可以使用而不是来启动要键入check的文件&#xff0c;其余的由编译器完成。 有关Hack的更详细的文章正在进行中&#xff0c;并将很快发布。 这种方法进一步提高了编译质量&#xff0c;使本地代码效率更高&#xff0c;而HHVMPHP则更快。

Is it really all about speed, though?

速度真的真的有关吗&#xff1f;

缺点 (The cons)

One of the main cons of HHVM at this moment is the inability to install custom extensions that depend on Zend Engine. As Cesar puts it – HHVM and ZE are like two cars that look alike, but their internals are completely different.

目前&#xff0c;HHVM的主要缺点之一是无法安装依赖Zend Engine的自定义扩展。 正如Cesar所说– HHVM和ZE就像两辆看起来相似的汽车&#xff0c;但它们的内部构造完全不同。

I would expand on the metaphor by saying the two cars have different engines, or different gear shifting systems. Trying to install Nitrous Oxide into an electric car simply won’t work, no matter how hard you try, because NOS depends on the combustion process which is absent in electric vehicles.

在此比喻中&#xff0c;我会说两辆车具有不同的发动机或不同的变速系统。 无论您多么努力&#xff0c;尝试将一氧化二氮安装到电动汽车中都是行不通的&#xff0c;因为NOS取决于电动汽车中不存在的燃烧过程。

This, unfortunately, means most of today’s extensions won’t be installable on HHVM unless converted, and since most extensions are open source projects that don’t get their developers paid, the situation reeks of a possible Python3-hell*.

不幸的是&#xff0c;这意味着除非将其转换&#xff0c;否则今天的大多数扩展都无法在HHVM上安装&#xff0c;并且由于大多数扩展都是开源项目&#xff0c;并且无法使开发人员付费&#xff0c;因此可能会出现Python3-hell *的情况。

Another disadvantage is also the same one we listed under pros – it’s developed by Facebook. While Facebook is still healthy these days, Cesar and Manuel speculate that it might suffer a decline in the coming years, and I tend to agree. Moreover, there is the possibility of Facebook making the daring attempt to move away from PHP altogether to something even faster and more structured like Dart – what happens if either of these scenarios occur? HHVM is open source, yes, but without Facebook’s bank and experienced hands behind it, and without a multi-billion userbase to regularly test and benchmark against, the development of HHVM will slow down drastically. The open source community simply lacks the expertise, resources and dedication to take over properly.

另一个缺点也与我们列出的优点相同-它是由Facebook开发的。 尽管这些天Facebook仍然健康&#xff0c;但Cesar和Manuel推测它在未来几年可能会下滑&#xff0c;我倾向于表示同意。 此外&#xff0c;Facebook有可能大胆地尝试从PHP完全转变为更快&#xff0c;更结构化的Dart之类的东西-如果出现上述两种情况&#xff0c;会发生什么&#xff1f; HHVM是开源的&#xff0c;是的&#xff0c;但是如果没有Facebook的银行和经验丰富的支持&#xff0c;并且没有数十亿的用户基础进行定期测试和基准测试&#xff0c;HHVM的开发将大大放缓。 开源社区只是缺乏适当接管的专业知识&#xff0c;资源和奉献精神。

Last but not least, there are already efforts to drastically improve PHP’s speed via other means. The Phalcon framework, which we’ve covered extensively, is already written in C and blazingly fast, and with their Zephir language, users can easily write actual PHP extensions for the Zend Engine version of PHP. This means closed source and/or compiled PHP applications that already work at near native speeds, almost rivaling HHVM.

最后但并非最不重要的一点是&#xff0c;已经在努力通过其他方式大大提高PHP的速度。 我们已经广泛讨论了 Phalcon框架&#xff0c;该框架已经用C编写并且速度非常快&#xff0c;并且使用Zephir语言&#xff0c;用户可以轻松地为Zend Engine版本PHP编写实际PHP扩展。 这意味着封闭的源代码和/或已编译PHP应用程序已经可以以接近本机的速度运行&#xff0c;几乎可以与HHVM媲美。

结论 (Conclusion)

There is no clear winning scenario here. If HHVM replaces ZE, the PHP community will benefit, though the new version might suffer in userbase size until HHVM can support common extensions, or until extensions are rewritten for it. If it remains as a separate project, we have two schools of thought – relying on vanilla HHVM and Hack to compile our frameworks and classes to the best possible native code, or relying on good old ZE PHP, our old extensions, and making do with cutting edge languages and frameworks like Phalcon and Zephir.

这里没有明确的获胜方案。 如果HHVM替换ZE&#xff0c;PHP社区将受益&#xff0c;尽管新版本可能会影响用户群&#xff0c;直到HHVM可以支持通用扩展名或为它重写扩展名为止。 如果它仍然是一个单独的项目&#xff0c;则我们有两种思路-依靠香草HHVM和Hack将我们的框架和类编译为最佳的本机代码&#xff0c;或者依靠良好的旧ZE PHP&#xff0c;我们的旧扩展以及先进的语言和框架&#xff0c;例如Phalcon和Zephir。

How ever you look at it, it’s clear PHP is ready for a new dawn. The advent of variadic function support and argument unpacking similar to that in other mainstream languages proves its readiness to mature, and excellent efforts by high quality low level developers drive the language and its runtime forward like never before. For us, the PHP users, the only way to lose this game is by not playing it at all.

无论您如何看待&#xff0c;很明显PHP已经为新的曙光做好了准备。 可变参函数支持和参数解压缩的出现与其他主流语言类似&#xff0c;证明了它已经成熟&#xff0c;并且高素质的低级开发人员的出色努力使该语言及其运行时间前所未有地向前发展。 对我们这些PHP用户而言&#xff0c;输掉这场比赛的唯一方法是根本不玩它。

Let’s not leave anyone behind. Got HHVM/Hack and/or Phalcon/Zephir tutorials? Throw them our way.

不要让任何人落后。 有HHVM / Hack和/或Phalcon / Zephir教程吗&#xff1f; 把它们扔给我们。

*Python3-hell refers to the fact that Python3 has been out for over 3 years now, is an improvement over Python2, and still has little adoption when compared to Python2.

* Python3-hell是指Python3已经问世3年以上的事实&#xff0c;它是对Python2的改进&#xff0c;并且与Python2相比仍然很少采用 。

翻译自: https://www.sitepoint.com/hhvm-vs-zend-engine-php-6/

php hhvm



推荐阅读
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • 浅解XXE与Portswigger Web Sec
    XXE与PortswiggerWebSec​相关链接:​博客园​安全脉搏​FreeBuf​XML的全称为XML外部实体注入,在学习的过程中发现有回显的XXE并不多,而 ... [详细]
  • 本文介绍了lua语言中闭包的特性及其在模式匹配、日期处理、编译和模块化等方面的应用。lua中的闭包是严格遵循词法定界的第一类值,函数可以作为变量自由传递,也可以作为参数传递给其他函数。这些特性使得lua语言具有极大的灵活性,为程序开发带来了便利。 ... [详细]
  • 翻译 | 编写SVG的口袋指南(上)
    作者:DDU(沪江前端开发工程师)本文是原文翻译,转载请注明作者及出处。简介ScalableVectorGraphics(SVG)是在XML中描述二维图形的语言。这些图形由路径,图 ... [详细]
  • Webpack5内置处理图片资源的配置方法
    本文介绍了在Webpack5中处理图片资源的配置方法。在Webpack4中,我们需要使用file-loader和url-loader来处理图片资源,但是在Webpack5中,这两个Loader的功能已经被内置到Webpack中,我们只需要简单配置即可实现图片资源的处理。本文还介绍了一些常用的配置方法,如匹配不同类型的图片文件、设置输出路径等。通过本文的学习,读者可以快速掌握Webpack5处理图片资源的方法。 ... [详细]
  • 如何使用Java获取服务器硬件信息和磁盘负载率
    本文介绍了使用Java编程语言获取服务器硬件信息和磁盘负载率的方法。首先在远程服务器上搭建一个支持服务端语言的HTTP服务,并获取服务器的磁盘信息,并将结果输出。然后在本地使用JS编写一个AJAX脚本,远程请求服务端的程序,得到结果并展示给用户。其中还介绍了如何提取硬盘序列号的方法。 ... [详细]
  • Whatsthedifferencebetweento_aandto_ary?to_a和to_ary有什么区别? ... [详细]
  • 本文介绍了如何在Mac上使用Pillow库加载不同于默认字体和大小的字体,并提供了一个简单的示例代码。通过该示例,读者可以了解如何在Python中使用Pillow库来写入不同字体的文本。同时,本文也解决了在Mac上使用Pillow库加载字体时可能遇到的问题。读者可以根据本文提供的示例代码,轻松实现在Mac上使用Pillow库加载不同字体的功能。 ... [详细]
  • SpringBoot整合SpringSecurity+JWT实现单点登录
    SpringBoot整合SpringSecurity+JWT实现单点登录,Go语言社区,Golang程序员人脉社 ... [详细]
  • 本文介绍了贝叶斯垃圾邮件分类的机器学习代码,代码来源于https://www.cnblogs.com/huangyc/p/10327209.html,并对代码进行了简介。朴素贝叶斯分类器训练函数包括求p(Ci)和基于词汇表的p(w|Ci)。 ... [详细]
  • ShiftLeft:将静态防护与运行时防护结合的持续性安全防护解决方案
    ShiftLeft公司是一家致力于将应用的静态防护和运行时防护与应用开发自动化工作流相结合以提升软件开发生命周期中的安全性的公司。传统的安全防护方式存在误报率高、人工成本高、耗时长等问题,而ShiftLeft提供的持续性安全防护解决方案能够解决这些问题。通过将下一代静态代码分析与应用开发自动化工作流中涉及的安全工具相结合,ShiftLeft帮助企业实现DevSecOps的安全部分,提供高效、准确的安全能力。 ... [详细]
  • 移动传感器扫描覆盖摘要:关于传感器网络中的地址覆盖问题,已经做过很多尝试。他们通常归为两类,全覆盖和栅栏覆盖,统称为静态覆盖 ... [详细]
  • 1.webkit内核中的一些私有的meta标签,这些meta标签在开发webapp时起到非常重要的作用(1) ... [详细]
  • GO语言 包 if..else.. for循环 switch 数组
    包1.什么是包1.新建一个文件夹,内部写很多go文件,但是包名必须一致,改文件夹就是一个包2.作用和优点包用于组织Go源代码,提供了更好的可重用性与可读性。由于包提供了代码的封装, ... [详细]
  • Apple iPad:过渡设备还是平板电脑?
    I’vebeenagonizingoverwhethertopostaniPadarticle.Applecertainlydon’tneedmorepublicityandthe ... [详细]
author-avatar
赵博钧石博
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有