PHP 8.0 Ready To Ship With Many New Features, Even Better Performance
PHP 8.0 is a very worthy successor to last year's PHP 7.4. Besides the JIT compiler there is a ton of work incorporated into this big version bump. Among the PHP 8.0 highlights are:
- PHP8 introduces the much anticipated Just In Time (JIT) compiler for further enhancing the speed of PHP scripts. More details on PHP's JIT compiler via this Wiki page.
- A number of other performance optimizations were also merged into PHP8.
- JSON support is now considered a core part of the language that's always available rather than being an optional module.
- Support for named arguments for being able to specify the name of arguments rather than their exact order.
- Support for attributes (or also known as annotations or decorators in other languages) for structured metadata on classes / properties / functions / methods / parameters / constants.
- Support for union types that can indicate multiple different types that can be used as parameters or return types on functions.
- Support for a static return type.
- The str_contains() function as an easier way for checking if a string is contained within another string, rather than having to use strpos and the like. Along similar lines are new str_starts_with() and str_ends_with() functions that are self explanatory.
- The Nullsafe operator has been added as a quick and easy way to apply null coalescing behavior on methods.
After PHP 8.0 has set sail I'll be through with some more comprehensive benchmarks, but for those curious below is a quick look at the PHP performance on an AMD EPYC 7742 server with Ubuntu 20.10. Not even with JIT enabled but just the straight-forward performance lift compared to the recent PHP 7.x series:
About a 10% out-of-the-box improvement with PHP 8.0 over the current PHP 7.4 stable series, but at least for some areas more performance can be squeezed with just-in-time compilation. Stay tuned for that data soon and the official PHP 8.0.0 release due out on Thursday.