top | item 6279241

A Look at PHP's Continuing Evolution

86 points| geerlingguy | 12 years ago |acquia.com | reply

185 comments

order
[+] jmadsen|12 years ago|reply
This article is important because there are still so many people who talk about how bad PHP is, based on their knowledge of some version from years ago.

There was (another) recent Ruby vs. PHP Bashfest some months ago that was essentially:

"PHP sucks. It can't do X...oh, it can? Well, it can't do Y...oh, it has been able to since 3 major release ago..well, it can't..."

PHP is far different than you probably think it is. I also can't help but feel that a huge number of they people who naysay it are only parroting things they don't even understand - I rarely hear them explain precisely why such and such quirk in the language is bad for programming

[+] eevee|12 years ago|reply
PHP's worst problem is an exacerbated form of what strangled Perl for many years (and still does, though they're actively fighting it): lots and lots of existing code that's really, really bad.

Adding new features doesn't help that. Only gradually deprecating old ones (or waiting a few decades) does, and that doesn't seem to be in PHP's blood.

[+] Killswitch|12 years ago|reply
Now days the only valuable thing a naysayer can say anymore regarding PHP is the inconsistent naming and needle/haystack placement, which really makes no difference other than to be a slight annoying having to go to php.net/function_name and just make sure it's right.
[+] jonahx|12 years ago|reply
To give a serious answer to this: While you are right that php bashing isn't always rooted in informed objectivity, the point you're making is missing something deeper.

It's sort of like when that person with a crush on you who you just don't like but who insists that if you really got to know them everything would be different. It's just not true.

Even if could prove a 1 to 1 correspondence between features of ruby and php, php would still be... ugly. It would still lack grace. The feeling of looking at a page of php code just wouldn't be as pleasing. I believe it is this raw, irrational difference, this visceral reaction to the physicality of the code, and not a misunderstanding of features (even if they are misunderstood) that accounts for the most of the hate you allude to.

[+] throwaway420|12 years ago|reply
I think it's important to remember that each programming language is good at different things. You wouldn't ordinarily try and build your blog with C++ just as you wouldn't ordinarily try and create a new operating system in JavaScript.

I think PHP is certainly capable of building larger systems and in recent years things like Composer and frameworks like Laravel are putting a lot of the PHP ecosystem on par with what's available for most other languages.

But I view PHP's sweet spot as small web sites. If you're a small business that needs to add a form or two, some simple DB access, send a couple emails (a few dozen to a few hundred lines of code) PHP is your ideal choice to get something up quickly, get it up on virtually any web host out there easily, and get back to focusing on your business. PHP's lack of elegance doesn't matter all that much when you're talking about a small project.

I think that Ruby/Python/etc are much more elegant when you get to the point that you're building larger web apps, but PHP is a very practical choice for lots of simple projects.

[+] adamors|12 years ago|reply
PHP 5.5 may be great but a lot of people in the real world still don't use namespaces and other things introduced in 5.3.

That is why people are always calling out PHP because most of the language and most of its developers appear to be in suspended animation.

Developers who use modern tools like Composer, Behat, frameworks other than Codeigniter etc. just aren't that many unfortunately. They're definitely not the majority, like they are over in the Ruby/Python camp.

[+] egeozcan|12 years ago|reply
I mostly agree with you. The awkward syntax and a nightmare API is here to stay for backward compatibility though. The most important point is, there are a lot of languages which are better than or at least on par with PHP on every aspect you can think of. PHP is definitely not a disaster, but everybody just need to move on.
[+] otikik|12 years ago|reply
The only feature I miss in PHP is un-gotcha-ness. Does it have that yet?
[+] camus|12 years ago|reply
Php still sucks, but the community is trying to build tools around it to make it better. But it doesnt make the language itself good. To make it good the first things to do would be to remove 90% of its silly "features".
[+] jimparkins|12 years ago|reply
"That 80% marketshare is not going anywhere anytime soon."

>> I have seen this mentioned many times before, and also worked in PHP development teams. However I think this statement is confusing. There is no way that php development or programming is 80% of the market. I suspect that when you crawl round the internet a lot of spam blogs and advertising content is based off of php based CMS like Wordpress and Drupal - because it is so easy to get a generic template driven website up and running with a good SEO basis. I can believe 80% of the websites that return content could be PHP based.

[+] eevee|12 years ago|reply
This is maybe the third comment about whether the 80% is lies, damned lies, or statistics.

I would much rather see a conversation about how other languages can bridge the gaps of "hello world in a browser isn't obvious" and "deployment is hard". Those are important and useful things to do, regardless of PHP's market share.

[+] ojbyrne|12 years ago|reply
This seems to be the authoritative source for that number: http://w3techs.com/

and the methodology:

http://w3techs.com/technologies

"We investigate technologies of websites, not of individual web pages. If we find a technology on any of the pages, it is considered to be used by the website. We include only the top 10 million websites (top 1 million before June 2013) in the statistics in order to limit the impact of domain spammers. We use website popularity rankings provided by Alexa (an Amazon.com company) using a 3 months average ranking. Alexa rankings are sometimes considered inaccurate for measuring website traffic, but we find that they serve our purpose of providing a representative sample of established sites very well."

I would argue that the numbers should be weighted by traffic - weighting all of the top ten million websites equally doesn't give an accurate picture.

[+] ihsw|12 years ago|reply
For a comprehensive list of new major language features, there is a wiki: https://wiki.php.net/rfc#implemented

One major feature not listed on the submitted article is namespaces, which is fairly major and it's just starting to reach critical mass in terms of reach. Despite being probably the most major feature in the past five years, most users should be able to enjoy using namespaces to their heart's content (along with all the libraries that utilize it, for example Amazon's latest PHP SDK (which is thoroughly impressive)).

For reference, Python3 came out in 2008 and it's also just starting to reach critical mass in terms of library support (cough third-party Django libraries).

There is also a third-party committee[1][2] with the goal of establishing things like coding guidelines, logging interfaces, HTTP request/response interfaces, and so forth.

[1] http://www.php-fig.org/

[2] https://github.com/php-fig/fig-standards

[+] eevee|12 years ago|reply
Why is Python 3 relevant? Porting a large Python 2 library to Python 3 (or, more likely, to both 2 and 3) is a significant undertaking. Porting a PHP library to use namespaces would largely be a matter of adding global aliases for backwards-compatibility, surely?
[+] stephenr|12 years ago|reply
I have to say I think the php fig is a joke, and I question the merits of anyone using it. Their own goals are a joke, much less the results.

They never set out to "define the best way to do X". They set out to "find the most common way the most common frameworks do X".

The results are equally questionable. Why would a "Framework Interop Group" need to care about shit like brace placement, indenting, or even file naming.

Their file naming is a big wtf for me, as their "standard" is set out the way it is, to support faux namespaces in pre php 5.3. PHP 5.2 reached 'end-of-life' status 2 1/2 years ago.

What gets me even more is the fucking hoops people constantly jump through to make ever more complex autoloaders for PHP.

there is native support in php for autoloading class files, including namespaces. it takes one line of code to set it up. one function call.

But that's not all: when these geniuses decided they wanted to implement a "reference" class loader, what did they call it? SplClassLoader. Because if enough idiots already follow your shitty "standards" they will think "ooh spl is in PHP this must be endorsed by them too!"??

Their logger interface is fucking laughable - who implements a logger, that has names exactly the same as syslog, and descriptions the same or similar to syslog, but ignores that syslog levels are INTEGERS and thus you can say quite easily "email be about errors below level x"

[+] jonahx|12 years ago|reply
There is something almost endearingly quaint about the author's earnest excitement over a verbose closure implementation and a procedural incarnation of the map method, like hearing a hunter-gatherer describe in awe the magic pictures in a box which is in reality a junked television set from 30 years ago.
[+] vectorpush|12 years ago|reply
Mmmmmm, sweet condescension. Nothing floats my boat higher than expressing superiority to PHP developers. They actually consider themselves to be real programmers, aren't they just the cutest?
[+] Killswitch|12 years ago|reply
It's this dead horse again. Let's beat it!
[+] nathan_long|12 years ago|reply
"Evolution" describes an unguided process which is declared successful as long as there are still living descendants.

Just sayin'.

[+] lbarrow|12 years ago|reply
Seems entirely appropriate in this case.
[+] eevee|12 years ago|reply
I don't think that's accurate. There's not really any notion of "success", and the most important part of the process is that changes are made effectively at random and either propel the species forward by some minor increment or never make it past being rare curiosities.

Wait...

[+] imperialWicket|12 years ago|reply
I don't think unguided is an appropriate descriptor for an evolutionary process (by definition or in the scope of PHP's history). However, your point about success is right on, and seems to fit the 'evolution' title and the language.
[+] smsm42|12 years ago|reply
In natural languages, words have multiple meanings. You may want to actually choose one that fits the case, not one that represents it in most perverted and unfavorable light. Just sayin'.
[+] verandaguy|12 years ago|reply
>unguided

I wouldn't say so. Most species (read: groups, not individuals) adapt when nature throws an exception they can't handle. Mutations capable of handling these exceptions become predominant in a group, while obsolete gene pools die off.

PHP shows too little of this for its progression over time to be called "evolution."

[+] nine_k|12 years ago|reply
On topic: PHP gets lambdas and closures; generators; traits.

In other words, PHP is definitely becoming a better, more reasonable language.

Of course it's still possible to write awful code using some old PHP features. But it's now far easier to write good, maintainable and expressive code, as one would in Python, or Ruby, or Go, or [you name it].

With this regard, PHP's evolution is not unlike C++'s.

[+] zaphar|12 years ago|reply
That has to be one of the strangest syntax's I've seen for closures ever. I get why it has to be that way sort of. (backwards compatibility) but it only serves to illustrate how PHP has hamstrung itself in the past.

Comparing PHP's evolution to C++ isn't exactly flattering either.

[+] jmstout|12 years ago|reply
"That 80% marketshare is not going anywhere anytime soon."

Whatever helps you sleep at night.

[+] betenoire|12 years ago|reply
PHP is unlikely to power the next start up. But I wouldn't be so cynical about it's success, especially in other segments of the web.
[+] programminggeek|12 years ago|reply
There is so much to dislike about PHP that the only thing I can say nice about PHP is that it's the easiest way to just deploy to any server ever. Beyond that, I don't think I would look to PHP to do anything ever if I had a choice of project language.
[+] shuzchen|12 years ago|reply
As someone that has had to mess with deploying large PHP project in a previous life, I'd have to disagree.

Using mod_php? Better fix your file permissions. Use any non-trivial language feature? - better make sure you have the right minor version installed. Use functions from the supposed standard library (e.g., anything from gd_*, xml, process control, cryptography modules)? - better pray PHP was compiled with those enabled. Use routing in your PHP app (and you're crazy if you don't)? - better pray apache is configured to accept your .htaccess, or port the mod_rewrite rules for the non-apache server you're on. And then all of this while futzing with the 3 different php.ini files scattered around the filesystem.

Between virtualenv and pip, deploying python has been loads easier, as is getting team members up and running with a dev server.

[+] epoxyhockey|12 years ago|reply
PHP's continuing evolution is also represented by the frameworks available for the language. For instance, Symfony2, paired with Composer, is (IMHO) analogous to Rails for Ruby and Django for Python.

HN can be an echo chamber for Ruby, Python and Golang. But outside of the Bay Area, a lot of people are very excited about Symfony2.

[+] AlexanderDhoore|12 years ago|reply
I have to create some push based (websockets or similar) web service that's event driven (events on the stock market). The prototype has been written in PHP, but doesn't do very much. I'm STRONGLY considering moving to nodejs.

We now use Composer for packages, an automatic classloader, an application framework and a database abstraction. But even with all this stuff, PHP is still an incredible pain.

PHP might be good at the situation where: on every request, you start a new script, that builds a webpage and sends it to the client. But once you try to make it do something else... Frustration awaits.

[+] meritt|12 years ago|reply
Your worldview ( Your last statement, that you think PHP is only suitable for a single request in a fcgi environment.) of PHP's capabilities are the pain point here.

What difficulties are you encountering trying to do basic pub/sub? Application developers have solved those exact same issues for decades now. Nodejs didn't invent "event-based programming".

[+] waivej|12 years ago|reply
"That 80% marketshare is not going anywhere anytime soon." - I had to look this up to confirm... It changes my perspective on the language.
[+] tel|12 years ago|reply
There's a lot of noise about PHP becoming a better language by adding features. Isn't it well established that adding features to a dud product is not the path to a better one?
[+] fideloper|12 years ago|reply
In my opinion, the only problem PHP suffers is that it's populated by many young, inexperienced developers. It's ease of use and low barrier of entry is a double-edged sword.

Many developers (especially ones building upon CMSes primarily) don't need to move beyond knowing Wordpress, ExpressionEngine or CodeIgniter.

So many "easy to use" products are built on it (Wordpress alone powers ~18% of "the internet") that it makes sense that we see so many mis- or un-informed developers crowding Google and StackOverflow.

You can make good code in PHP. You can also learn other languages. You can, more importantly, learn when it's a good idea to use other languages. However, if people don't need to learn more, many won't. That's human nature.

Saying "PHP sucks" is missing the point that other people have other needs, other experience and other education levels from you.

PHP, as a language with low barrier to entry, can fulfill many's needs without requiring a CS education, and without writing their own framework/cms.

Source: 18% of internet: http://thenextweb.com/insider/2013/07/27/wordpress-now-power...

[+] smsm42|12 years ago|reply
>>> is that it's populated by many young, inexperienced developers.

It's not a bug, it's a feature. PHP is by design the language for young, inexperienced developers. It's like saying the only problem a school has is that it's full of kids.

[+] Osiris|12 years ago|reply
There are whole books written about how terrible JavaScript is, and yet it is one of the most popular languages today. People have learned to work around the quirks and develop best practices to avoid pitfalls.

PHP is an actively developed language. It has its pitfalls and problems, but is also provides more modern ways to use the language that avoid those problems.

[+] camus|12 years ago|reply
> it is one of the most popular languages today

Javascript is popular because people have no choice but to use that. Let's be truthfull here.

Only a few people actually like this language.If it wasnt for the web nobody would use javascript ,which is totally inconsistent with the strongly typed DOM.

Kudos to microsoft as they created DHTML.

[+] lysol|12 years ago|reply
Another thing I didn't notice earlier, after perusing the implemented RFCs: More Python-like array syntax:

[1, 2, 3] ['key1': 'val1', 'key2': 'val2']

We've been on 5.4+ at work for some time now and if I'd know that a year ago it would've saved me a lot of array()s and visual noise.

[+] anaphor|12 years ago|reply
I don't find the closure syntax simple really, since it's essentially a hack to copy the variable into the current scope, since PHP doesn't support lexical scope.
[+] zura|12 years ago|reply
Any chance it can get rid of the dollar sign?
[+] agumonkey|12 years ago|reply
PHP is maturing but large user base and projects may slow the diffusion of idioms based on the new additions. Or maybe the next major releases of say joomla, wordpress and such have redesigned their core to leverage that. Maybe they'll follow the eclipse ecosystem-wide synchronisation of projects.
[+] janson0|12 years ago|reply
I often believe that these arguments over which language is better are a detriment to actually getting stuff done. But here I am commenting on stuff, rather than coding... so what does that say about me? :)