Author: Manuel Lemos
Viewers: 1,484
Last month viewers: 20
Categories: PHP community, PHP opinions
Read this article to learn about a brief story of PHP 7, the major new features of PHP 7, the results of a survey carried in the last weeks to evaluate the intentions of the PHP developer to adopt PHP 7, and what to expect for future PHP versions.
Contents
The PHP 7 Story
Major New Features of PHP 7
PHP 7 Adoption Survey Results
PHP 7 Survey Results Analysis
The Future of PHP 7
Conclusion
The PHP 7 Story
PHP 7 is the first major PHP release since PHP 5.0.0, which was released in 2004, more than 11 years ago.
It is not like the PHP core developers have been sleeping for all this time. PHP 6 had an ambitious plan to bring transparent support for Unicode strings to PHP. However, its development stalled and PHP 6 was canceled in 2010.
After that period PHP had several releases with some important new features like namespaces in PHP 5.4 but nothing really big that justified a major new release.
Still in 2010 Facebook announced the PHP HipHop compiler. This was a compiler that would convert PHP into C++ code which then would be compiled into native machine code with a C++ compiler. Despite the concept was great and it brought some performance improvements to PHP, it was not very practical because it would take very long to compile PHP scripts to native machine code.
After that Facebook moved on to a different approach. They created HHVM (HipHop Virtual Machine) which would compile PHP into native machine code using a JIT engine (Just In Time). That would take much less time and still achieved significant performance improvements.
But apparently Facebook was not happy with the features of PHP and in 2014 launched Hack, a language derived from PHP that brought many features that PHP was missing, like for instance stricter type checking for all data types and built-in asynchronous programming support.
Not very long after that Dmitry Stogov of Zend announced a somewhat secret branch of development of PHP which by than it was called PHPNG.
Major New Features of PHP 7
Initially the idea of PHPNG was to investigate the introduction of a JIT engine that would work with the Zend Engine based version of PHP. However, with further research he realized that other improvements could be performed on the PHP code to make it run much faster.
PHPNG became the basis of the next major PHP version which was called PHP 7 to avoid confusion with the original PHP 6 plans that were canceled.
Many other features were added to PHP 7 including strict type for scalar values, anonymous classes, nested classes, and the possibility to compile the PHP engine and optimize for specific applications like Wordpress using Performance Guided Optimizations (PGO).
PHP 7.0 was originally meant to be released in October but since there were still some outstanding bugs it was delayed until December.
PHP 7 Adoption Survey Results
PHP 7 release is definitely one of the most exciting events on the PHP world in the latest times due to many of the anticipated features such as those mentioned above.
Many developers are eager to start using PHP 7 but not all of them will be using it right away. Therefore a survey was created to evaluate the intentions of the PHP developers to adopt PHP 7.
Basically the survey just asked three questions:
1. Are You Going to Use PHP 7 in Production?
2. Are You Going to Use PHP 7 in your Development Environment?
3. What is the latest PHP version you are using in production?
526 developers answered the survey, so the results should reflect the reality of the opinions of many PHP developers.
1. Are You Going to Use PHP 7 in Production?
Yes, I am using already since versions before the first stable 7.0.0 release | 21 | 4% |
Yes, I want to start using only since the official 7.0.0 version is released | 104 | 19.8% |
Yes, I will wait a few weeks or months after the 7.0.0 version is released | 196 | 37.3% |
It depends on the customers that I work for | 44 | 8.4% |
No, not anytime soon, I need to migrate a lot of my code and that will take me a long time | 58 | 11% |
No, not now, I only plan to use it for future new projects | 64 | 12.2% |
No, only if my hosting company forces me to use it and does not provide an older version | 20 | 3.8% |
Other | 19 | 3.6% |
2. Are You Going to Use PHP 7 in your Development Environment?
Yes, I have been using continuously for a while | 41 | 7.8% |
Yes, I used it a few times just to test its features | 60 | 11.4% |
Yes, I want to start using only since the official 7.0.0 version is released | 218 | 41.4% |
Yes, I will wait a few weeks or months until I have more time to check it out | 112 | 21.3% |
It depends on the customers that I work for | 11 | 2.1% |
No, not now, I only plan to use it for future new projects | 62 | 11.8% |
No, only if my hosting company forces me to use it and I need to fix my code | 13 | 2.5% |
Other | 9 | 1.7% |
3. What is the latest PHP version you are using in production?
PHP 7.0 | 10 | 1.9% |
PHP 5.6 | 299 | 56.8% |
PHP 5.5 | 111 | 21.1% |
PHP 5.4 | 59 | 11.2% |
PHP 5.3 | 38 | 7.2% |
PHP 5.2 | 5 | 1% |
PHP 5.1 | 0 | 0% |
PHP 5.0 | 1 | 0.2% |
PHP 4 | 0 | 0% |
Other | 3 | 0.6% |
PHP 7 Survey Results Analysis
From the first question we can see that the majority of the developers are not early adopters. They want to use PHP 7 but they would rather wait a bit until it is more stable.
Although there were 8 release candidate versions and the PHP test suite that evaluates if PHP passes all the tests is quite extensive, developers know that there will be bugs or backwards incompatible changes that will take them some time for the eventual fixes of PHP or the developers code base that needs to be fixed.
There is also an significant number of developers that will only want to use PHP 7 in new projects probably because the current projects are very critical and cannot be affected by changes that PHP 7 may cause.
The second question was more to understand how curious PHP developers are about PHP 7. The results revealed that more developers are interested in testing it in the development environment because it is safe.
If anything breaks their code, they can already have an idea of much work they will have to fix, especially if they have their own application test suites ready to see if many tests fail.
The third and last question was meant to see how up to date are the versions of PHP that developers are using.
There is a small minority that is bravely already using PHP 7 in production. We don't know if they are using it for critical projects but I believe it is very unlikely.
Well the good news is that majority of the developers are using already PHP 5.6. In the worst case there are developers still using PHP 5.3. probably because that is what their hosting company provides or because newer versions break their code.
Still PHP 5.3.11 should be at least the minimum version that everybody should use these days because older versions have serious bugs that may halt your server.
If you are curious, from the 3 developers that said they use Other PHP version, only one actually said HHVM. To use HHVM you need to control your hosting environment and probably compile it manually. The vast majority of the PHP developers do not have that possibility or the technical capabilities to do so.
The Future of PHP 7
Well now that PHP 7 is finally being released you may be wondering what will be the next step. There are some features already planned but others we can only speculate.
Some of the plans for new features we have already been discussing in the Lately in PHP Podcast. If you are curious, make sure you follow the episodes of the podcast audio or subscribe to the YouTube channel to be notified about the latest PHP feature discussions.
PCO is the PDO for Cryptography
One thing that we already know is that there will be an abstraction extension named PCO that will be like PDO but for cryptography.
PHP Static Code Analyzer
There is also a tool being developed by Rasmus Lerdorf named PHAN that is a PHP static code analyzer. The idea is to detect possible bugs just by analyzing your PHP code without having to run it. It takes advantage of the new AST (Abstract Syntax Tree) extension being introduced in PHP 7.
Asynchronous Programming with Async and Await
Another possibility is that PHP provides better built-in asynchronous programming support using the async and await constructs. These are keywords that allow you to run multiple parallel tasks in the same script, so you do not have to wait for one to perform another.
Do not confuse asynchronous programming with multi-threaded programming. This is something that PHP can already perform using the pthreads extension.
The greatest advantage of the async and await constructs is that you no longer have to deal with the callback hell. This means that if you need to wait for some asynchronous operation like accessing the file system, database or remote servers, you just use the await keyword so the script will continue to the next statement when the asynchronous operation is finished.
The async and await keywords require some non-trivial changes to PHP because it will need to deal with internal event loops. However, PHP core developers have already started discussing the possibility to implement the async and keyword constructs because they need to make those keywords reserved before other developers start using them.
Furthermore Facebook Hack language also supports async and await. I suspect that Facebook developers may help PHP core developers on bring async and await to PHP.
You may wonder if having these constructs in PHP is it really important. It is important once you learn their advantages.
Many developers have moved on to Node.js because of its support to asynchronous programming. Node.js does not yet support async and await keywords but it is just a matter of time because that is one of the features of EcmaScript 7 which will be the base of future JavaScript versions to be used by Node.js.
Developments like this may be considered even more important specially after the recent announcement of Wordpress to move as much as possible to JavaScript, including Node.js and React framework on the server side.
Apparently this was a step they did to make more efficient use of their server based that hosts Wordpress.com blogs. We don't know yet if the Wordpress community will embrace that project because there are thousands of plugins that rely on PHP.
Standalone Web Server
PHP already comes with a standalone Web server but it is not really recommended for production environments.
Once PHP comes with built-in asynchronous programming support, it will be easier to develop HTTP Web server written even in pure PHP just like you can do with Node.js.
This could make PHP more flexible in terms of features and more efficient in terms of handling parallel requests with less memory, especially when combining asynchronous programming with multi-threaded programming based on pthreads.
Conclusion
PHP 7 was definitely a great giant leap for the PHP. However the world keeps revolving and PHP must follow new trends like some of the mentioned above.
Still we should all congratulate all the developers that gave away their time and skill to make PHP so much better like PHP 7 is now.
If you liked this article or want to ask a question regarding PHP 7 features and adoption expectation, post a comment here now.
You need to be a registered user or login to post a comment
1,616,820 PHP developers registered to the PHP Classes site.
Be One of Us!
Login Immediately with your account on:
Comments:
3. Async PHP? - Gary Bhat (2015-12-04 04:06)
Is Async supported in the current PHP7 or we wait for it?... - 2 replies
Read the whole comment and replies
2. It makes plenty of sense to upgrade - Guillermina Gonjon (2015-12-03 06:17)
PHP7 has better chances of being adopted faster than previous PH... - 1 reply
Read the whole comment and replies
1. Matto - m (2015-12-03 06:09)
2nd pie chart is wrong... - 1 reply
Read the whole comment and replies