Everything you Need to Know About PHP 8
Everything you Need to Know About PHP 8
PHP is a widely-used open-source general scripting language that is highly suited for web development. Over the years, PHP has come a long way and is today incredibly advanced and able to support countless different websites, business platforms and mobile apps.
PHP 8, the next major release of the popular server-side development language created by Rasmus Lerdorf, should be available by the end of the year. The release is expected to bring with it plenty of powerful new features, as well as great language improvements.
Among the main new features of this version, we note the expected support for the JIT (Just-in-Time) compilation already confirmed, among others, by developer Joe Watkins.
On a practical level, we can define JIT as a mode that allows compilation to be performed at runtime – that is, while an application is running. This is why it is also called "dynamic translation".
Compiling the PSP and JIT
In the specific case of PHP, you should refer to the Zend VM and the opcodes (opcodes). These are the parts of a machine language instruction that specify the operations to be performed.
The scripts present in the sources are compiled in opcodes which are low-level elements, a feature which makes them more efficient when it is necessary to convert them into machine code. This allows you to reduce the time required for compilation. This also allows you to run opcodes through Zend VM directly during runtime.
It is also important to keep in mind that the JIT support was designed to be an independent part of OPcache, the system which allows opcodes to be stored in cache, and follows that compilation will only take place when this will be requested.
On the contrary, the machine code produced depends on the reference architecture, which makes it possible to host it directly at the level of the central unit and not at the level of the virtual machine.
Not just for the web
But what are the implications of a PHP version which, after years of waiting, will allow you to take advantage of JIT builds?
In many ways, this is a feature that has a revolutionary impact as it will allow you to use the language even in contexts other than the web which, until now, has been the go-to environment.
For the language
In addition, this new mode should prove ideal for all projects that involve heavy use of the resources provided by the processors and, in general, in all scenarios where performance must be higher than what the PSP can currently guarantee.
Not just benefits
The implementation of JIT for PHP is structurally much simpler than what can be found in the Python interpreter PyPy, in the V8 for JavaScript and in the HHVM virtual machine.
However, especially at an early stage, PHP developers and system administrators will be faced with greater complexity, more difficult maintenance procedures, and greater debugging difficulties.
Other new Features
Named Arguments
Named arguments allow you to pass in values to a function by defining the value name. When you do this, you won’t need to take their order into account, and you can also ignore optional parameters.
New static return type
Although self-return was always possible, static was not a valid return type until the introduction of PHP 8.
This function is beneficial to many developers, especially considering the dynamically typed nature of PHP.
Inheritance with Private Methods
Previously, PHP used public, protected, and private methods to apply the same inheritance checks. This basically means that the same method signature rules as the protected and public methods should be followed by private methods.
New Stringable Interface
The Stringable Interface can be used to type anything that implements __toString(). Whenever a class implements __toString(), it auto-implements the interface behind-the-scenes, therefore there’s no need to manually implement it.
In addition to the above, PHP 8 will have plenty of other features certain to support your website in unique and powerful ways.
Whether you are a start-up or a well-established business, you’re going to need a flexible and versatile PHP, no matter the type of website you run.
EWM. is a leading web development agency in Geneva. With almost 20 years of industry experience, we are suitably equipped to support your digital marketing and coding needs in a professional and empowering way.
To find out how PHP 8 could benefit your business, contact the team at EWM. today to discuss your unique needs.