12 марта 2013 г.

Next big thing in PHP

What’s the next big thing in PHP? Or more accurately, how do you get to wish/want for a next big thing in PHP?
PHP currently is seen as a jack of all trades, master none by most of people outside of PHP world and it’s starting to look the same way for people who are using it as well.
How did we got there?
  • PHP is simple to learn, hard to master;
  • Once you master it you realize that you need more out of it but it can’t deliver due to various limitations, be it language or performance;
  • When your business grows beyond a certain limit you discover that the performance you need from the engine isn’t as great as it must be for your needs. Since you start adding more technologies and servers and hire more people to optimize and so on, you discover that it starts to cost more than you’d like you to;
  • Since the economy will push you to use something that can deliver more performance or more robust applications, more and more major players will not use PHP anymore;
  • If the above happens, the demand for programmers will start to slowly shift from PHP to other languages (most programmers will adapt to market demands or there’ll be an artificial increase in need for other programming languages);
  • When some more seasoned programmers start asking for features that are missing in the language or solutions to problems that would include language changes there’s a world of pain incoming for them (see property accessors, named parameters, threads and others).
  • A (very) big factor in this is the actual community. We keep requesting new features, faster release cycles, better performance and whatnot, without thinking first of the people who work on the project and how we can help them.
  • There’s a serious lack of contributors to the PHP core itself. “Contribute to PHP” you say (which I’ll do), but some/most need to: learn C, learn internals, start with small patches/private demos, propose patches and there’s no guarantee that the patches will make it into a official release;
My opinion is that, by keeping this up, PHP will slowly die. Maybe it will take 10 years, maybe 5, but it will.
Enough with the (semi-)ranting. What can be done?
Well, I’ve been saying it for a long time now. PHP 6 should get here but in no way it should be the PHP we all know. No.
PHP6 should be one hell of a BC Break. So big that nothing above basic math operations should work anymore.
Some of you might jump and shout “Wait!? What?! That’s bad!!!! Are you insane?” No, I really am not. Now it should be the perfect time to do it.
The language lacks many, many features that should have been added, but now, even if people would be willing to work on them, they still couldn’t add them. If we, PHP community keep asking more features to be added on top of a broken foundation which was never meant for such things then we’ll all be in a world of pain and we’ll be the ones to blame for it, not anyone else.
I love PHP and I can’t thank enough to the current contributors to it but really, something has to change.
Zend Engine needs to catch up with what developers need/want/expect. We need more higher level things in PHP as we need/want/have to build more complex applications with it.
All the requirements are already there. Lets have a roadmap with features to be released in PHP6.X and then go from there.
We, the users, could help them to write a better documentation, if not contribute to the source itself, for the internals as well as the language itself. It would help everybody, especially when there are persons out there that are willing to lend a helping hand to the core developers with this huge, but important task in the future.
Core people, help yourself by making a better internals, dumping all the legacy code/support and improve anything that can be improved.
  • Make PHP6.0 a version where no new features are added unless they provide speed gains or fix the existing features.
  • Keep speed in mind at all times, we all need more speed. There’s a couple of suggestions for this like having opcode cache natively (PHP 5.5 is about to bring that if all goes well), there’s a talk about using AST for the parsing engine.
  • Bring us strong typed values but make them optional. We’ll use them in our frameworks/applications and you’ll be able to apply optimizations on this. Unbox variables when parsed and get rid as much as possible on ZVALs.
  • Use a smarter parser which knows when to use strings and when to use integers by the return types we are hinting in our functions or/and by allowing us to use type hints for primary data types.
  • Maybe it would take 2-3 years to get it done, at least to a alpha/beta stage, but heck, I’m willing to bet that most of the people would wait for it. Stop doing anything after PHP 5.5. Just do security/bug maintenance on it and focus on PHP6.
  • Make a poll running on php.net and ask what your users will fill like if they need to wait 2-3 years and get a new, better, faster language.
Would people be confused about the changes? With great frameworks/libraries/ORMs such as Symfony2, Doctrine2 and the others which practically reborn the way most of programmers think about doing applications in PHP, I really don’t see a problem with them adopting it fast and best of all, helping out in providing documentations on things for their users.
This should be the next big thing in PHP. Collaboration and better community interface for both worlds, users and devs.
Help us help you on PHP6, help us making a better world for everyone using PHP.

This post was done by: Florin Patan and Cristian Datculescu. We’ve wrote this on a first person basis as it reflects our common views about the problem and solving it. Additional thanks go to Cosmin Iancu for providing a nice review of this :)