Also, I can find no reference to PHP having anonymous functions/lambdas prior to 5.3, which is the version number given in both the linked article and PHP docs.
There is a difference between a closure and a lambda. PHP's create_function() implemented lambdas in PHP version 4.0.1 which was released in June 2000. 5.3 added closures.
You said "lambda was added to PHP in June 2000". That is clearly not the case, and now you are trying to play semantic games to pretend you are still right. The function create_function() is not lambdas. It isn't even anonymous functions, they are still named, you just don't know the name. You can easily get a duplicate function error from using create_function(), which means it is most certainly not anonymous.
Note that php.net/create_function even points you to their page on actual anonymous functions, which they erroneously claim are the same as closures.
My point wasn't that these things don't exist in other languages. Again, I'm not saying that PHP is objectively better than anything else. I know not to play that game. All that I'm doing is remaining steadfast in my claim that PHP doesn't deserve all the flak that it gets and that the language deserves consideration for a whole variety of use cases. That's all!
But if it isn't objectively better than similar languages in any way, then why does it deserve consideration? "You can work around and/or avoid most of the horrible problems in PHP" isn't a compelling argument in favour of PHP when every other language just doesn't have those horrible problems to begin with.
PHP is still usable, sure, but there's just not many compelling reasons to do so, except in certain cases where it does offer a clear-cut advantage (low-friction, newb-friendly development and deployment of simple dynamic sites, for example).
I also find the "there's tons of spaghetti code in other languages" argument tiresome. That's true, but well-designed languages tend to help keep people off that path - or at least do a better job of doing so. PHP is not one of those languages, hence the need for a "PHP the Right Way".
As asserted in the post, PHP is indeed used on a ton of websites. Most of these websites were written when PHP was the best tool for the job. But languages evolve. Other languages have learned the lessons of PHP and improved upon it.
PHP has done a fine job of "modernizing" itself lately, but it's still stuck with a lower quality overall design than some of the alternatives, and those alternatives have kept moving forward at the same time too. It reminds me a lot of IE's "look, we've implemented that thing that the good browsers had 3 years ago" announcements. It's great that PHP is not standing still, and that continued improvement must be awesome for existing projects that are built on PHP.
But for me, starting new projects in 2012, there's zero compelling case for using PHP, just as there are many old languages that would have been "the" choice once upon a time, but are now replaced by better things.
I thought we agreed that different solutions required different tools?
It's 2012 and all of our new apps our driven by PHP+Symfony2 with AngularJS on top. This combination has been huge for us (my company, I mean).
Maybe what should be answering is what "things" are better compared to PHP development with equal expertise. Like, what will RoR do for me that my existing setup won't? Why swap Symfony2 for ExpressJS and a multitude of NPM packages?
I'm alays eager, like most of the HN community, to be sold on the next great thing that makes my life easier, code cleaner, and site faster. But aside from language design, I haven't seen any apples-to-apples comparisons on the applications of these "better things."
14 comments
[ 3.1 ms ] story [ 39.8 ms ] threadI'm just going to say that's it's a bit amusing that of the things he lists as "revelations" python has had since:
1. when dinosaurs roamed the earth (lambda)
2. 2003 (wsgi)
3. years ago (pip/easy_install)
4. ages (db-api)
Also, I can find no reference to PHP having anonymous functions/lambdas prior to 5.3, which is the version number given in both the linked article and PHP docs.
The key thing with a lambda in python is that it is defined at the usage site.
so you can do:
Whereas in php that would be: Yes, the usage strings as code adds yet another level of WTF to this example.Note that php.net/create_function even points you to their page on actual anonymous functions, which they erroneously claim are the same as closures.
More cogently: If PHP is where python was in 2007, why wouldn't I want to use the python of 2012?
I also find the "there's tons of spaghetti code in other languages" argument tiresome. That's true, but well-designed languages tend to help keep people off that path - or at least do a better job of doing so. PHP is not one of those languages, hence the need for a "PHP the Right Way".
As asserted in the post, PHP is indeed used on a ton of websites. Most of these websites were written when PHP was the best tool for the job. But languages evolve. Other languages have learned the lessons of PHP and improved upon it.
PHP has done a fine job of "modernizing" itself lately, but it's still stuck with a lower quality overall design than some of the alternatives, and those alternatives have kept moving forward at the same time too. It reminds me a lot of IE's "look, we've implemented that thing that the good browsers had 3 years ago" announcements. It's great that PHP is not standing still, and that continued improvement must be awesome for existing projects that are built on PHP.
But for me, starting new projects in 2012, there's zero compelling case for using PHP, just as there are many old languages that would have been "the" choice once upon a time, but are now replaced by better things.
I thought we agreed that different solutions required different tools?
It's 2012 and all of our new apps our driven by PHP+Symfony2 with AngularJS on top. This combination has been huge for us (my company, I mean).
Maybe what should be answering is what "things" are better compared to PHP development with equal expertise. Like, what will RoR do for me that my existing setup won't? Why swap Symfony2 for ExpressJS and a multitude of NPM packages?
I'm alays eager, like most of the HN community, to be sold on the next great thing that makes my life easier, code cleaner, and site faster. But aside from language design, I haven't seen any apples-to-apples comparisons on the applications of these "better things."