Live data from Hacker News

An Exceptional Change in PHP 7.0

daveyshafik.com

11–20 of 53 posts

Re: An Exceptional Change in PHP 7.0

#11
post #8
post #6

Earlier quoted context omitted.

PHP is much more of a static language than a dynamic one. Therefore it has more in common with Java/C++ than with Python, Ruby, or JavaScript. It's also a very pragmatic choice for an OO system.

PHP wasn't always what it is now, that's OPs point. They are where they chose to go. Probably in the search of legitimacy, they chose to follow the most enterprisey language.

I personally feel like PHP OOP is much more like C++. It's just not surprising that two high-level languages based on C++ end up near the same place.

PHP is heavily based on C so choosing to make it's OOP features like C++ isn't a big leap.

Plus PHP is still far less enterprisey than Java so maybe the OO model isn't the real issue.

Re: An Exceptional Change in PHP 7.0

#12
Both the LogicException and the RuntimeException branches seem kind of pointless... They all describe exceptions that happen with values at runtime and I expect I'd have trouble picking one in a given circumstance. Mostly I see it leading to a lot of inconsistent uses in practice. At least 4 of them would be legitimate choices for a string thats too short, for example.

Ah, PHP.

Re: An Exceptional Change in PHP 7.0

#13
post #2

Out of curiosity, why does PHP use backslashes in throwable names?

This is the official explanation as to why the delimiter is a backslash - https://wiki.php.net/rfc/namespaceseparator

To this day, the table on that page remains one of my favourite examples of PHP's badly thought out design.

Re: An Exceptional Change in PHP 7.0

#15
post #2

Out of curiosity, why does PHP use backslashes in throwable names?

Heh, I was wondering the same. As others have pointed out, it looks like it's the namespace separator. Now someone has to explain why on Earth you need the namespace separator if these class names are already in the namespace?

PHP has an incredible knack for almost copying other languages' features, but making them uglier in some random way, for no particular added benefit.

(I know, I'm a hater... but seriously, why?)

Re: An Exceptional Change in PHP 7.0

#16

Earlier quoted context omitted.

This is the official explanation as to why the delimiter is a backslash - https://wiki.php.net/rfc/namespaceseparator

To this day, the table on that page remains one of my favourite examples of PHP's badly thought out design.

PHPs design and grammar precluded using any of the other existing operators. The backslash is really the best choice and in practice it works pretty well. The actual debate on the separator choice was very very very long.

Re: An Exceptional Change in PHP 7.0

#17
post #2

Out of curiosity, why does PHP use backslashes in throwable names?

Heh, I was wondering the same. As others have pointed out, it looks like it's the namespace separator. Now someone has to explain why on Earth you need the namespace separator if these class names are already in the namespace? PHP has an incredible knack for almost copying other languages' features, but making them uglier in some random way, for no particular added benefit. (I know, I'm a hater... but seriously, why?…

The namespace separator is not required if already in the correct scope. I am not sure why the author decided to include them in the examples.

Re: An Exceptional Change in PHP 7.0

#18
post #2

Out of curiosity, why does PHP use backslashes in throwable names?

Heh, I was wondering the same. As others have pointed out, it looks like it's the namespace separator. Now someone has to explain why on Earth you need the namespace separator if these class names are already in the namespace? PHP has an incredible knack for almost copying other languages' features, but making them uglier in some random way, for no particular added benefit. (I know, I'm a hater... but seriously, why?…

> Now someone has to explain why on Earth you need the namespace separator if these class names are already in the namespace?

You don't. This is just illustrating these classes are in the global namespace.

> PHP has an incredible knack for almost copying other languages' features, but making them uglier in some random way, for no particular added benefit.

Well you have a case for "no added benefit" typically they aren't ugly for a random reason. There's a lot of very necessary reasons for the way these things work while making a language which is still PHP. PHP isn't precompiled. PHP has autoloading of classes. PHP allows code to be imported into other code. Combining namespaces with all the other existing features isn't an easy task.

Re: An Exceptional Change in PHP 7.0

#20
post #8
post #6

Earlier quoted context omitted.

PHP is much more of a static language than a dynamic one. Therefore it has more in common with Java/C++ than with Python, Ruby, or JavaScript. It's also a very pragmatic choice for an OO system.

PHP wasn't always what it is now, that's OPs point. They are where they chose to go. Probably in the search of legitimacy, they chose to follow the most enterprisey language.

Indeed, a few years ago Paul Biggar (CircleCI) tried to compile PHP extensively and said it was far too dynamic to do "good" compilation (I'm distorting his words a lot here).
Post reply on HN