21 ms·
A Look at PHP's Continuing Evolution
- nathan_long 13y ago"Evolution" describes an unguided process which is declared successful as long as there are still living descendants. Just sayin'.
- imperialWicket 13y agoI 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.
- lbarrow 13y agoSeems entirely appropriate in this case.
- deleted 13y ago[deleted]
- verandaguy 13y ago>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."
- deleted 13y ago[deleted]
- krapp 13y agoFine. Let's call it "intelligent design" then.
- eevee 13y agoI 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...
- smsm42 13y agoIn 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'.
- ihsw 13y agoFor a comprehensive list of new major language features, there is a wiki: https://wiki.php.net/rfc#implemented 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/ http://www.php-fig.org/ [2] https://github.com/php-fig/fig-standards https://github.com/php-fig/fig-standards
- eevee 13y agoWhy 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?
- ihsw 13y agoPorting a library from non-namespaced to properly-namespaced code is fairly significant, and there should be little-to-no backwards incompat. issues between pre-php-5.3 and post-php-5.3. The difference is a fairly large undertaking both in code size and technical challenge.
- stephenr 13y agoI 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"
- jmstout 13y ago"That 80% marketshare is not going anywhere anytime soon." Whatever helps you sleep at night.
- deleted 13y ago[deleted]
- betenoire 13y agoPHP 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.
- wyck 13y agoWhy not? , programmers might hate it but they don't always drive start-up direction. Getting something to market and being useful is just more important than semantics when you're facing a budget. Lots of start-ups started with PHP (foursquare, groupon, facebook, etc, etc) because of the minimal cost and the convenience offered by popularity. If it works out and they get funding they can spend all that sweet cash on whatever they prefer. Mobile apps and heavy REST services maybe not, but websites are still popular, and PHP is playing catch up for those services too.
- betenoire 13y agoI don't disagree. I was responding to the sarcastic comment about PHP, not really trying to address using it for a start up. Our start up used it as well. It's not the sexiest or most fun environment, but it works and it's the devil I know.
- janson0 13y agoThis is my situation too. I mean, I know PHP and I know CodeIgniter. I have tons of already ready to deploy code based in those idioms, so why port everything to laravel? or Ruby? Maybe down the line or something... but not when speed matters.
- MindTwister 13y agoI hadn't spotted the iterators earlier, interesting.
- troels 13y agoReally? They have been around since 5.0, which is nearly a decade old. See some of the other interfaces SPL provides here: http://php.net/manual/en/book.spl.php http://php.net/manual/en/book.spl.php
- MindTwister 13y agoI meant generators, as in yield
- waivej 13y ago"That 80% marketshare is not going anywhere anytime soon." - I had to look this up to confirm... It changes my perspective on the language.
- kaeruct 13y agocould you share what you found? i'm curious
- kragniz 13y agoI'm guessing this: http://w3techs.com/technologies/details/pl-php/all/all http://w3techs.com/technologies/details/pl-php/all/all
- eevee 13y agoI'm pretty sure w3techs is just measuring who has what in their `Server` headers, so even a static site that happens to have mod_php available would still ping as PHP. For the same reason, Python is virtually nonexistent—because nobody uses mod_python.
- waivej 13y agoThis one too: http://w3techs.com/technologies/overview/programming_language/all http://w3techs.com/technologies/overview/programming_languag... This page was also interesting... Keep in mind, it's only the top 10,000,000 in Alexa: http://w3techs.com/forum/topic/22677 http://w3techs.com/forum/topic/22677 "In total, we have a few thousand technology indicators, many of them can be used - directly or indirectly - to determine the server-side language. The number of sites where we don't identify any language is relatively small. The reason why we don't include it in the statistics is, that we want to show shifts in the relative popularity of technologies, not distorted by changes in our abilities to detect them."
- epoxyhockey 13y agoPHP'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.
- treeface 13y agoAnd there's also Laravel, which is partially built on Symfony and generally maps a little closer to what is possible in Rails.
- epoxyhockey 13y agoOne of the things I love about Symfony2 (other than the framework) are the following bundles: -FOSUser -FOSRest -Sonata Admin In a few minutes, I have a multi-user website, complete with REST server and a user administration interface. As someone without a lot of hands-on experience with Laravel, is there a similar combo of Laravel bundles that can get me up and running with a multi-user website?
- treeface 13y agoLaravel has built-in auth support and a bunch of good Composer packages that can add more features. It's also got RESTful and resourceful controllers built in and a very awesome routing system. You can use any admin/cms package, but this one I made specifically for Laravel and the Eloquent ORM: https://github.com/FrozenNode/Laravel-Administrator https://github.com/FrozenNode/Laravel-Administrator
- pearjuice 13y agoLaravel 4 is amazing, too. Symfony2 feels like a beomoth to me (a few versions later and it will probably be on-par with Zend in terms of over-architecturing as it is going right now) whereas Laravel is lean and elastic yet offering the complete package in an easy consumable format.
- anaphor 13y agoI 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.
- eevee 13y agoPHP supports lexical scope; it's just local to the current function. The actual problem is that PHP automatically initializes variables even on read—the same reason all globals have to be manually "imported", even if they're only read from. Similar to the problem Python 3's `nonlocal` solves, except imagine a world where Python didn't have NameErrors and instead initialized every unrecognized name to None.
- anaphor 13y agoIs there much PHP code that relies on this "feature" or could they have changed it to actually search in the enclosing scope if something was read, and avoided the silly "use" keyword? I mean it's not like PHP has an actual spec, so they can change it whenever they feel like it as long as it doesn't break much.
- eevee 13y agoVariable declaration is pretty core to the language. Remember register_globals? That was only a problem because so much code relied on having undeclared variables act like empty strings. I suppose they could have made it work differently just for nested functions, but that's a major inconsistency, it's not clear how it would interact with globals, etc.
- stephenr 13y agoregister globals didn't "make undeclared variables act like empty strings". register globals imported request parameters from the query string and post body into the global variable scope. having undeclared variables "act like empty strings" is related to non-strict variable comparison (== vs ===) and either silencing errors, or not displaying/caring about them.
- AlexanderDhoore 13y agoI 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 13y agoYour 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".
- deleted 13y ago[deleted]
- themstheones 13y agoTrue, PHP is a great scripting language.
- AlexanderDhoore 13y agoEvent driven programming seems tacked on to php. I don't know if I want to run php as a daemon and then do some hackery to get IPC. It's not made for that...
- wwweston 13y agoI've written a lot of PHP, and while I can think of a number of ways you might use PHP to provide the backend for websocket-like communication (writing a long-running server, using multipart responses, adaptive polling), it seems pretty fair to me to say this isn't the place where PHP is strongest out of the box. Particularly compared to nodejs. If you know of a PHP runtime-host, library, or even just a development approach that makes supporting it as easy as nodejs, though, I'm all ears.
- lysol 13y agoAnother 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.
- adduc 13y agoThe colon-based syntax was voted down. What went live in 5.4 was support for brackets in lieu of array() // Typical array syntax $arr = array('key' => 'asdf'); // Supported in 5.4+ $arr = ['key' => 'asdf'];
- jimparkins 13y ago"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 13y agoThis 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.
- nine_k 13y agoI thought Ruby has all but bridged it?
- eevee 13y agoWith what? Rails? Doesn't that require generating a whole "project" (whatever that is) with a bunch of directories and files and then figuring out where everything is and... PHP requires opening index.php and typing "hello world". Obviously that's not going to work anywhere else, but something like Flask (or Sinatra) is much closer. Deployment, maybe. The biggest stumbling block is that no matter how magical a deployment solution anyone invents, it's worthless unless there are free/cheap hosts that come with it installed and have cPanel integration.
- mcleod 13y agoMeteor?
- ojbyrne 13y ago
- programminggeek 13y agoThere 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 13y agoAs 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.
- stephenr 13y agoOut of the box php generally works, which is often touted as a benefit. Personally i think if you can afford a server you can afford 20 minutes time for someone who knows what they're doing. Every one of your examples tells me that you chose not to invest in those 20 minutes. Here's a hint: there is a reason "developer" and "administrator" are usually different roles.
- shuzchen 13y agoOut of the box php generally works so long as you have trivial php code (that doesn't take advantage of new language features, doesn't need routing, doesn't need to write to the filesystem, and doesn't common library modules). Needless to say, that generally rules out any serious project out there. I'm not saying I chose not to invest in those 20 minutes, I'm saying there's nothing about PHP that makes it inherently easier than other things to deploy real projects. You still have to deal with version incompatibilities, you still have to deal with configuration, you still have to deal with differing resources. That applies to all stacks.
- usamec 13y agoEvolved shit is still shit. Half of issues mentioned here (http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de...) are still not solved.
- themstheones 13y agoI doubt that many of the main gripes about PHP will ever be solved without a "breaking changes" version like python had. The PHP community isn't likely to get behind something like that.
- tangledweb 13y agoI've always loved that fractal of bad design rant. Many of his gripes follow really neatly from his initial analogy of the hammer with claws on both sides. Let's say you want to hammer in a nail. You reach into a tool box and pull out something that you think is a hammer. Instead it has claws on both sides, and is in fact a nail puller. You don't know much about tools so you use it to beat in nails, all the while grumbling to your friends that it's a bad hammer. For instance, I don't see how you expect to "solve" most of the "issues" in that. The fact that the author does not like the way == works in a weakly typed language is not a bug. Sure, it present bugs in code when programmers don't know how implicit type casting works, but it's really nice if you do.
- eevee 13y agoHello, author here. You're not the first to scoff at my hammer description, but perhaps you can explain to me what kind of nail puller looks exactly like a hammer but with two claws, or why it would be useful to have the exact same tool on both sides of the handle. (This is still a PHP analogy.) I don't see how to solve most of the issues, either. That sucks, and I genuinely sympathize with Zend on this, but it doesn't make them not-issues. As I think I said, they'd be acceptable if they were reasonable tradeoffs, but many of them are not. Your == counterargument seems apologetic and trivially applied to anything: whenever a program is wrong because the language violated expectations, it's the programmer's fault for not having memorized some matrix of arcane rules. Languages aren't perfect and human beings have wildly differing expectations, but ultimately we only have programming languages to make it easier to express ourselves—no one's stopping you from writing the next big web 2.0 thing in x86 machine code. So yes, when it's difficult to reliably ask a language "are these things the same" without learning paragraphs of gotchas, that's bad. Glad you enjoyed the article!
- nine_k 13y agoOn 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 13y agoThat 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.
- smsm42 13y agoWhat's so strange in it? It looks pretty much exactly like JS, for example, with one small addition of "use" clause. It has very little to do with "backwards compatibility" - since there's nothing to be backwards compatible to, closures didn't exist before.
- zaphar 13y agoThe use clause is the weird part. I would imagine the reason it has to be there is because it would be bad if functions that weren't written with closures in mind previously suddenly turned into closures. Otherwise why even bother?
- smsm42 13y agoThe reason has nothing to do with that. The reason is that closures don't need most of the variables from parent scope, but if they were imported, since PHP is refcounting they'd keep a lock on those variables even after exit from the original scope - as long as the closure exists - even though nobody actually needs them. Since PHP has $$var (and other things like this) we can not know in advance which variables the function uses in local scope, so if we did automatic scope importing, we'd have to keep the whole scope of the parent function for the lifetime of the closure in case some of the variables would be needed. This, if parent scope contained some large objects, would result in a memory and performance hit each time closures are used. Thus, it was decided that we'd make scope importing explicit (the use clause), so if you want to import variable, you have to say it. Experience shows that vast majority of closures need no more than one or two vars from parent scope, so the tradeoff is fine. Of course, if closures would import dozens of variables regularly, we'd have to seek different solution, but this is not the situation. Additional benefit - though not the reason - is readability improvement, as now you know where each variable is coming from, otherwise reading in-closure code you wouldn't know if the variable that is not mentioned anywhere is a mistake or it is actually expected to be imported from outside. BTW, C++11 is using the same idea: https://en.wikipedia.org/wiki/Anonymous_function#C.2B.2B https://en.wikipedia.org/wiki/Anonymous_function#C.2B.2B though they have catch-all syntaxes which in PHP wouldn't work since PHP is a dynamic language.
- jonahx 13y agoThere 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 13y agoMmmmmm, 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?
- eevee 13y agoGP's phrasing aside, it does make the article read as though the author has never used any other closure implementation (and, by extension, any other programming language).
- vectorpush 13y agoWell, perhaps he hasn't used any other closure implementation... why would that merit mockery? I doubt the same tone would be taken if he were a Ruby novice adulating over block syntax. It's just hip to condescend to PHP developers.
- eevee 13y agoI'm only observing that the article comes across weirdly as a result, especially when the author makes judgments like "simple". Not defending the condescension. (Though the same tone might well be taken if he were a Ruby novice writing articles titled "A Look at Ruby's Continuing Evolution".)
- Killswitch 13y agoIt's this dead horse again. Let's beat it!
- jmadsen 13y agoThis 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
- egeozcan 13y agoI 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.
- Killswitch 13y agoNobody needs to move on. PHP is here to stay and isn't gonna disappear anytime soon, it controls a large portion of the internet, if you don't like it, don't use it. Nobody is forcing you to use it.
- rbanffy 13y agoNobody needs to move on from COBOL. It's here to stay and isn't going to disappear anytime soon. It runs a large portion of all financial operations. If you don't like it, don't use it. Nobody is forcing you to.
- Killswitch 13y agoGood. I'm glad you're catching on. Next step is to learn that all languages have their strengths and weaknesses and your personal preference means nothing to anyone but you.
- tel 13y agoThere'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?
- zura 13y agoAny chance it can get rid of the dollar sign?
- agumonkey 13y agoPHP 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 13y agoI 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? :)
- fideloper 13y agoIn 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-powers-18-9-of-the-web-has-over-46m-downloads-according-to-founder-matt-mullenweg/ http://thenextweb.com/insider/2013/07/27/wordpress-now-power...
- smsm42 13y ago>>> 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.
- ausjke 13y agoLaravel looks great, is it still a one-person-mainly project? if so that really concerns me, same as Gitlab project.
- Osiris 13y agoThere 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 13y ago> 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.