Home >Backend Development >PHP Tutorial >PHP Fights HHVM and Zephir with PHPNG
Key Points
This article is sponsored by NewRelic. Thank you for your support for the sponsors who made SitePoint possible! Previous versions of the article incorrectly described PHPNG as a JIT compiler. This is not the case, and the necessary modifications have been completed. Please see the bottom of the article for more information.
In this series of changes, another new voice has emerged: PHPNG.
As Manuel Lemos introduces, PHPNG is a new branch of PHP that will appear in a future version of PHP that has not yet been determined.
Wait, what?
PHPNG was presented by Dmitry Stogov in an internal newsgroup topic. Dmitry is responsible for the performance and optimization of Zend, mainly dealing with the Zend engine. NG upgrades focus on rewriting the core parts of the Zend engine for better memory allocation to PHP data types.
Excerpt from Reddit:
NG exists because the experiments Zend performed when it introduced JIT failed in the real world because of the current design of the engine, mainly because we are allocating everything all the time. NG patches have changed the specification, so we no longer allocate zvals by default, which improves performance and allows for a cleaner API.
As with any attempt to "improve PHP", this attempt has its pros and cons.
Faster execution means faster resource allocation, faster request processing, and greater request throughput. The preliminary results are encouraging (1, 2).
Performance still needs to be benchmarked against other alternatives, but the 10-30% improvement cannot be underestimated.
Since this upgrade is done on the official Zend engine, not on the runtime, it almost guarantees compatibility with the current extension. One of the biggest reasons people hesitate to migrate to HHVM is that the basic extensions they are used to using are unavailable (in my case Phalcon). Personally, a faster PHP engine that supports Phalcon will make me less concerned about the upgrades Hack offers today.
So it guarantees extended compatibility…and so on. Yeah? Oh, no.
Incredibly good.
Not all extensions are supported, some tests fail, and we have more ideas for improvement.
To be fair, NG is still very young. Much younger than anything we’ve dealt with in the PHP world and more like a major update – so some compatibility issues are inevitable. But I agree with Manuel that when upgrade time comes, this may be a pain point for most shared hosting providers.
Although I am quite against shared hosting providers, I fully understand the problems this may bring. We both had similar confusion when we tried to get providers to “use PHP5” and the most recent time they needed to use a newer version of PHP, so getting them to make a big shift that could introduce BC disruptions would be a daunting task .
This fear of change will solidify the use of older versions of PHP, which in turn will breed more extremely unqualified PHP developers working on outdated code, completely ignoring best practices and vulnerabilities. In short, we will repeat history. It may sound like the end of the world, as some have pointed out, but I’m deeply involved in all areas of PHP every day and reaching the lowest quality areas with a full inbox, I see what we’re in now Location and where we will go. However, not everything is dark – solutions like Heroku and DigitalOcean will enable people to run the latest and customized versions of PHP at a price less than (or equal to) shared hosting providers.
My sincerest hope is that the core team will be able to perfect the new Zend engine to a level that remains backward compatible with all extensions, but will issue compilation warnings to all extension developers who fail to comply with NG specifications and best practices .
The core development team is notorious for adapting to slow changes. Modern features that existed in other languages for many years were rejected in the past and were not implemented until a few years later.
Whether this is due to a lack of vision for the core development team, as Anthony and Phil’s post says, or because it’s too small and underfunded to make any major changes quickly, it doesn’t matter – slow internally Meaning we may never be able to see NG in public and get rid of the “alpha” state, as is the case with the mysterious PHP6.
This reminds us of the last point.
Due to the inherent slowness often seen in PHP core development teams, it will only provide performance upgrades when NG is implemented (if it is actually implemented). By then, Hack and HHVM (much more than standard PHP) will offer so many additional features that matches will be manipulated and PHP will have no chance of winning.
The type prompts available today in Hack and Zephir will take root in these implementations. Multithreaded, compiled, standalone web server – all of these features are available in alternative solutions today, and they are almost all ready to go into production. While the core development team is working on some of these features, and PHP may have IIS support before HHVM (which is obviously important to some), I personally still think this is not quick enough for the official side of PHP progress.
Even if the core team does decide to vote for "yes" on all these special features that have problems and needs, it will take them too long to implement - and they will be behind by default unless the paradigm shift is introduced and their entirety is changed How to work. Moving the source code to GitHub is a good move, but it just touches the surface.
In other words, Rasmus himself is said to think that HHVM has become the core engine of PHP in a few years is not a science fiction scenario.
Leaving Facebook-related ownership (which has many negative implications in itself), HHVM pushes developers in the right direction by showing how such upgrades can be made. This drives innovation and forces those who have long been content with their throne to stand up and stretch their legs to see if they can still run. Facebook’s aggressiveness forced the PHP world to revisit and think about what is going on, and it soon became popular.
The competition is awesome. I feel optimistic about it wherever this brings us.
After having an email with Phil Sturgeon and after reading the official statement, I have edited some of the above text. In short, I classify PHPNG as JIT, which is obviously not, but just a performance upgrade, which will allow the core team to develop a suitable JIT compiler later.
PHP and Zephir are both scripting languages for web development. PHP is a widely used open source language, while Zephir is a high-level language that allows developers to write extensions for PHP. Zephir provides static typed syntax, which helps prevent possible errors in PHP. However, PHP has a larger community and more available resources, which can be beneficial for developers.
HHVM (HipHop virtual machine) and PHPNG (PHP new generation) are both engines for executing PHP code. HHVM is developed by Facebook and uses an instant (JIT) compilation method to achieve excellent performance. On the other hand, PHPNG is an internal project of PHP that aims to improve the performance of PHP applications. It does this by changing the way PHP represents values and objects internally, resulting in significant memory usage improvements.
Zephir is no longer actively maintained according to recent updates. This means that while the language is still available, it may not receive updates or fixes for any potential issues that may arise.
Zephir offers developers many advantages. It provides static typed syntax, which helps prevent errors. It also allows developers to write extensions for PHP, thus providing a way to improve the performance of PHP applications.
The purpose of creating Zephir is to provide a high-level language that allows developers to write extensions for PHP. The goal is to improve the performance of PHP applications by allowing developers to write critical code parts in languages that are easier to optimize and manage.
PHPNG improves the performance of PHP applications by changing the way PHP represents values and objects internally. This leads to significant memory usage improvements and may lead to faster execution time for PHP applications.
Despite the emergence of HHVM and Zephir, PHP is still a widely used web development language. While HHVM and Zephir provide performance improvements, PHP has a huge community and abundant resources available. The future of PHP looks promising and is constantly working to improve its performance and capabilities.
Yes, one of the main advantages of Zephir is that it allows developers to write extensions for PHP. This may be a way to improve performance of your PHP application.
Scripting language is a programming language used to automate tasks that would have been performed step by step by step by step by step by human operators. On the other hand, a high-level language is a programming language that has a strong abstraction with computer details, making it easier to read and write.
The instant (JIT) compilation method of HHVM improves performance by compiling bytecode into machine code before execution. This allows optimization and can significantly increase the execution speed of PHP applications.
The above is the detailed content of PHP Fights HHVM and Zephir with PHPNG. For more information, please follow other related articles on the PHP Chinese website!