PHP 8.0: The Upcoming Version of PHP and The Inclusion of JIT

PHP 8.0: The Upcoming Version of PHP and The Inclusion of JIT
As we know that PHP7 is awesome, it has huge improvements over PHP5, either we talk in terms of speed or performance. Also, it brought us the much-awaited scalar type hints for better user experience.

However, it would not be wrong to say that no language is perfect and requires to be updated now and then. So, when it comes to PHP 8, users' expectations are very high. Well, the one place where everyone loves to see PHP8 go is into more real-time features. That's because this feature will help not to use other languages in one PHP project only for the sake of real-time.

Due to the real-time era, the internet is transitioning to real-time. And, therefore, even users want their content fast. Few languages already have something for real-time purposes like JavaScript has Node.js, Python has Tornado, but PHP still doesn't have anything. So, as per the announcement, we can suppose that PHP has evolved, and the next major legs are PHP 8.0.0 and the JIT (Just-in-Time) compilation.

Let’s begin with a brief introduction of PHP and its previous versions first to understand it better.

Introduction to PHP

PHP: Hypertext Preprocessor started as a small open source project that eventually evolved as more and more people found out how useful it was. Way back in 1994, Rasmus Lerdorf, a Danish-Canadian programmer, unleashed the first version of PHP. PHP, embedded in HTML, is a server-side scripting language which is very much popular now.

The language is used to manage dynamic content, session tracking, databases, and even build entire e-commerce sites. It is integrated with various popular databases, including MySQL, Oracle, PostgreSQL, Sybase, Microsoft SQL Server, and Informix.

PHP, especially when compiled as an Apache module on the Unix side, is pleasingly zippy in its execution. And, once the MySQL server starts, it executes highly complex queries with huge result sets in record-setting time.

Moreover, the language supports a huge number of major protocols such as IMAP, POP3, and LDAP. Making an n-tier development a possibility for the first time, PHP4 added support for Java and distributed object architecture (CORBA and COM). As another best feature, PHP is a forgiving language. Yes, it tries to be as 'forgiving' as possible. And, its Syntax is C-Like.

Another best thing about this language is that it is easy to use as not only the advanced developers but also the newbies can use it. And it still retains a healthy list of innovative features for highly professional programmers to develop.

Previous Versions of PHP Till Now

Till now, several versions of PHP has evolved. So, let’s check out the PHP versions already available in the market here.

1.0      8th June 1995            

2.0      1st November 1997             

3.0      6th June 1998 to 20th October 2000

4.0      22nd May 2000 to 23rd June 2001

4.1      10th December 2001 to 12th March 2002

4.2      22nd April 2002 to 6th September 2002

4.3      27th December 2002  to 31st March 2005

4.4      11th July 2005  7th August 2008

5.0      13th July 2004 to 5th September 2005

5.1      24th November 2005 to 24th August 2006

5.2      2nd November 2006 to 6th January 2011

5.3      30th June 2009 to 14th August 2014

5.4      1st March 2012 to 3rd September 2015

5.5      20th June 2013 to 21st July 2016

5.6      28th August 2014 to 31st December 2018

7.0      3rd December 2015 to 3rd December 2018

7.1      1st December 2016  to 1st December 2019

7.2  30th November 2017 to 30th November 2020

7.3 6th December 2018 to December 2021

The Status of Just In Time (JIT) in PHP 8.0

There's no information about the upcoming features of PHP 8.0 yet. Still, there is a strong conjecture of the inclusion of JIT in version 8.0 of PHP.

Though, to understand well about Just-in-Time (JIT) in PHP, let’s first learn about it in brief. A way of optimizing running code is Just in time compilation. This popular method is already used by the Java Virtual Machine (JVM), the popular V8 JavaScript VM from Google as well as HHVM. Hence, JIT is no silver bullet because both of these already use it.

Before the current evolution (PHP 7.x), the PHP development focused on improving PHP performance by using a JIT. Though,  this attempt yielded substantial improvements in the benchmarks, yet proved to offer small improvements in real-world applications such as Joomla or WordPress.

Following the work which was done for version 7.0 of PHP and offering significant improvements in it, the performance in PHP 7.1 and PHP 7.2 have been rather modest. And, that’s because the team again started working on the JIT implementation. As of now, there is no deep analysis of the JIT PHP project, but there are some encouraging results.

A Brief Introduction to JIT (Just-in-Time Compilation)

In computing, a way of executing computer code that involves compilation during the execution of a program – at run time – rather than before execution is what we called just-in-time (JIT) compilation (also called dynamic translation or run-time compilations).

Most frequently, this carries source code or more commonly bytecode translation to machine code, which is further executed directly. A JIT compiler implemented system continuously analyses the code being executed.

Also, it identifies parts of the code where the speedup gained from recompilation or compilation would outweigh the overhead of compiling that code.

Why is JIT Introduced in PHP?

As we mentioned earlier, HHVM (an alternative runtime which Facebook developed & uses) utilizes JIT. It is even faster and better in comparison to the official PHP engine which was deployed in PHP 7.0.

So, because of the HHVM’s extreme popularity or high demand from the PHP community across the world to go for JIT Engine again, Zend and PHP Group is up for it and also determined to bring it up in the next major release PHP 8.0.

While a code written in PHP 5 is executed in PHP 7 even without change, as an outcome, the performance doubles. It is not because of the changes in the engine but the other optimizations in PHP 7.0.

Hence, we can believe that an update in the engine is certainly going to improve the performance in various folds. As we know the standard of HHVM, the performance level can easily double, or we can say that when words a code written for PHP 7 will implement in version 8.0, its time of execution will be halved.

In other words, to make the compilation during the execution of the program or runtime, JIT or Just-In-Time compilation is one of the best ways. And, as it's best, there is no question of compilation before execution, especially where the huge time is consumed. It is possible to consider it to be a dynamic compilation process and yield a faster result that static or before runtime compilation surely.

Since many of the .Net framework implementations and the Java implementation are dependent on JIT already, it is okay for PHP to take advantage of dynamic compilation and enhance its performance up to the next level.

To understand more, let's study the reasons in detail.

1. PHP Hits the Brick Wall

Since 7.0 version of PHP, many improvements have been made, including optimizations for HashTable, specializations in the compiler for certain sequences, specializations in the Zend VM for certain opcodes, and many more. And, it could be said that now PHP has reached the extent of its ability to be improved any further after so many improvements.

2. PHP for Non-Web Scenarios

After adding JIT in PHP, it will allow its use in scenarios for which it is not even considered today, i.e., in other non-web, CPU-intensive scenarios, especially where the performance benefits will be essential.

3. More Secure Implementations & Faster Innovations

The team will be able to develop built-in functions in PHP due to JIT support instead of C without any huge performance penalty. Yes, the use of JIT would make PHP less susceptible to overflows, memory management, and other similar issues associated with C-based development.

How are the PHP Programs Compiled?

There is a virtual machine called Zend VM in PHP. The human-readable scripts are compiled into instructions, known as OpCodes, which are further understandable to the virtual machine.

Compiled instructions, OpCodes, are faster to translate to machine code as compared to the original PHP code, and the reason behind it is they are low-level. This execution stage is known at compile time. And, these compiled instructions aka opcodes are further executed by the Zend VM in the runtime stage.
To make compilation happen only when it is required, JIT is being implemented as an almost independent part of OPcache and an extension to cache the opcodes. Moreover, JIT will treat the instructions generated for the Zend VM as the intermediate representation in PHP. Further, to make the host of the code as the CPU directly and not the Zend VM, it will then generate architecture-dependent machine code.

Release Date of PHP 8.0

According to previous updations, it takes years for the PHP team to come up with a major update. The last major version was released in December 2015. Though, we have a few minor updates every year like 7.0 to 7.1 and 7.2. Well, we can say the next major update is going to be PHP 8.0.

And, unlike the case where PHP 5.0 followed PHP 7.0 without the release of PHP 6, there will not be any omission this time.

The release of PHP 8.0 is not scheduled as it is a major leap and might take some years. But “Larry Garfield,” one of the reputed names in the PHP world, tweeted that PHP 8 is going to come out in September 2021.

Recent Changes

Ahead of PHP 8.0, the first alpha release of PHP 7.4 is now available. And, soon release candidates will culminate with the official PHP 7.4.0 release around the end of November.

It has been reported that to make for an exciting release, the PHP 7.4 release is bringing many notable additions, while one is looking forward to PHP 8.0 with its JIT and more as the eventual successor to 7.4. Amidst the work in PHP 7.4 at this point comprises:

1. At first, the preload feature which can significantly improve the performance of PHP on web servers by preloading functions/classes that will survive as long as the web-server is active to avoid recompilation or checking to see if the source file(s) were modified. It can yield 30-50% speed-ups in the initial tests. 

2. Moreover, other PHP performance improvements happened outside of the preloading scope. 

3. The PHP FFI extension for a Foreign Function Interface was added after it didn't end up making it for last year's PHP 7.3 to let PHP code call native functions/variables/data structures defined in the C programming language. Hence, to open up new possibilities for the PHP programming language, the PHP FFI extension is set to go for PHP 7.4. 

4. The FPM system service of the language has been hardened. 

5. The Hash extension of the PHP is now an integral part of the language and can no longer be disabled. 

6. Within the PHP OpenSSL streams support, TLS 1.3 support and several fixes throughout are done. 

Concluding Thoughts

One of the major advantages that PHP has is it comes with every Linux system and also runs on Windows web servers. It complies that the language is likely to stay in the web-building ecosystem for quite some time. Recently, the language was also ranked eighth on the TIOBE Index, indicating a good deal of developer's interest.

Based on the reports of Netcraft’s monthly web survey, the language’s presence is split mostly between Nginx web servers (29 percent), Microsoft (19 percent), and Apache (29 percent).
Covetus Get in Touch
Get free consultation right away via text message or call
Send Massage