I also find it funny that people who hate on PHP used to hate on JavaScript for many of the same reasons and they now have an unhealthy, public love affair with it.
Javascript used to be clunky due to cross-browser issues. These are mostly resolved now (at the language level).
PHP, on the other hand, has always been clunky. For example, it's often said that parsing is a solved problem. Try telling that to PHP:
$y = new stdClass;
$y->foo = function() { echo "World"; };
$y->foo(); // "No such method 'foo'"??!
I've written quite a few parsers, but still have no idea how PHP's could end up like this. Here are some recent 'features' from PHP 5.4 and 5.5 which every other parser on the planet would have handled from day 1:
- Passing an arbitrary expression instead of a variable to empty() is now supported. (PHP 5.5)
- Function array dereferencing has been added, e.g. foo()[0]. (PHP 5.4)
- Class member access on instantiation has been added, e.g. (new Foo)->bar(). (PHP 5.4)
I've written quite a few parsers, but still have no idea how PHP's could end up like this.
Have you ever tried to parse code with a set of context sensitive rules (like, not using yacc, but writting your parser case by case at hand) and context free regular expression (don't use look ahead at all, and you also can't look behind)? PHP errors look a lot like this.
Comments
Javascript used to be clunky due to cross-browser issues. These are mostly resolved now (at the language level).
PHP, on the other hand, has always been clunky. For example, it's often said that parsing is a solved problem. Try telling that to PHP:
$x = function() { return function() { echo "Hello"; }; }; $x()(); // Syntax error??!
$y = new stdClass; $y->foo = function() { echo "World"; }; $y->foo(); // "No such method 'foo'"??!
I've written quite a few parsers, but still have no idea how PHP's could end up like this. Here are some recent 'features' from PHP 5.4 and 5.5 which every other parser on the planet would have handled from day 1: - Passing an arbitrary expression instead of a variable to empty() is now supported. (PHP 5.5) - Function array dereferencing has been added, e.g. foo()[0]. (PHP 5.4) - Class member access on instantiation has been added, e.g. (new Foo)->bar(). (PHP 5.4)
Have you ever tried to parse code with a set of context sensitive rules (like, not using yacc, but writting your parser case by case at hand) and context free regular expression (don't use look ahead at all, and you also can't look behind)? PHP errors look a lot like this.