The new PHP 8 stable version has finally been released! This new PHP version introduces a number of changes, added improvements and new, exciting features. But what are they? Let’s find out!
PHP JIT (Just-in-Time) Compiler
PHP is an interpreted language, meaning that it is not compiled like Java or C for example. In fact, PHP is translated to machine-readable code during runtime. Hence why the new feature - Just-in-time (JIT) compiler, is quite important when it comes to increasing performance and efficiency.
JIT is a new technology that will partially compile the code at runtime, allowing for this compiled version to be utilized later. It’s like a cached version of the interpreted code, which is generated at runtime.
As we already said, this will help improve performance substantially, due to the fact that calculations are executed much faster in PHP 8 using JIT in comparison to PHP 7. The following video from Zeev Surasky, co-author of the JIT proposal for PHP 8 illustrates these improvements in more detail:
How does PHP 8’s JIT feature work?
In general, this new JIT technology works in the following way. A new tool will be introduced, named the ‘monitor’, which will be observing the code as it is running and executing.
When the monitor notices that a piece of code is being re-executed, it will proceed to mark that snippet as ‘warm’ or ‘hot’, depending on the execution frequency.
The ‘hot’ code snippets are then compiled as optimized machine code, allowing them to later on be used instead of the actual code.
Some say that this makes JIT look and work similarly to the technology behind OPCache. However, the two are also vastly different in terms of the logic that they employ and the ways in which they process code.
Subscribe to our newsletter.
Join 5000+ subscribers and get:
New PHP 8 features
If we move our focus away from the new PHP JIT compiler, there are also a number of other changes and improvements that have been made and incorporated into the new PHP version. The aim of these changes is to make PHP 8 more reliable, efficient and optimal when designing and creating projects.
The following list represents some of the major changes that have been introduced with PHP 8:
- Constructor Property Promotion
- Validation for Abstract Trait Methods
- Union Types
- Weak Maps
- Throw Expression
- Arrays Starting With a Negative Index
As we mentioned, these are only a handful of the changes. The full list and thorough descriptions about the changes can be found in PHP 8’s release documentation.
Additionally, PHP 8 also introduces a number of new functions with some of the announced ones being:
PHP 8 is available for all VPSBG shared hosting accounts
Given that we focus on customer’s privacy and providing exceptional hosting services, we want to always keep our services up to date. Hence why we are making PHP 8 available for our shared hosting services. If you want to make the switch to the new version, you can do so from your cPanel.
If you are unsure how to do it, don’t worry - we have a detailed tutorial on how to set a specific PHP version for your account.
Overall, the new PHP version brings a lot of useful and innovative features that will undoubtedly increase performance and make the use of the language easier.