Live data from Hacker News

An Exceptional Change in PHP 7.0

daveyshafik.com

21–30 of 53 posts

Re: An Exceptional Change in PHP 7.0

#21
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?…

if you do not include the namespace separator, and you import a namespace with the same name defined, you'll have a not-so-pleasant surprise. e.g.:you use "Exception" to catch all exceptions, and someone defines "SQL\Exception", then you import "SQL", and now all your catch blocks stop working. But don't worry. This is business as usual in the PHP world.

Re: An Exceptional Change in PHP 7.0

#22
post #8

Earlier quoted context omitted.

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.

But you, like the OP, fail to communicate exactly WHY this is a bad thing. You just take it for granted that your point stands on its own without an explanation. Why NOT Java?

Java is a fairly ugly OO system, basically. It's purely my opinion, of course, but not an uncommon one.

Since I don't have to use PHP I'm not too upset. I was really just lamenting the state of the world.

Re: An Exceptional Change in PHP 7.0

#25
post #6

I just don't get why, of all the OO systems out there to inspire an engineer, the PHP people picked Java.

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.

You could say that PHP == "static language", even if you maybe can't say PHP === "static language"?

Re: An Exceptional Change in PHP 7.0

#26

Earlier quoted context omitted.

But you, like the OP, fail to communicate exactly WHY this is a bad thing. You just take it for granted that your point stands on its own without an explanation. Why NOT Java?

Java is a fairly ugly OO system, basically. It's purely my opinion, of course, but not an uncommon one. Since I don't have to use PHP I'm not too upset. I was really just lamenting the state of the world.

Same thing as before, you've stated it's ugly, but haven't given any specific examples of why you think this.

Re: An Exceptional Change in PHP 7.0

#27

Earlier quoted context omitted.

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.

I still don't get what stopped them from using any of the existing operators.

Re: An Exceptional Change in PHP 7.0

#28

Earlier quoted context omitted.

Java is a fairly ugly OO system, basically. It's purely my opinion, of course, but not an uncommon one. Since I don't have to use PHP I'm not too upset. I was really just lamenting the state of the world.

Same thing as before, you've stated it's ugly, but haven't given any specific examples of why you think this.

do we really need to see bad java examples to understand his opinion?

Re: An Exceptional Change in PHP 7.0

#29
post #23

Wow this thread reeks of negativity

It's a thread about PHP on Hacker News. Even if there were no comments at all it would still reek of negativity.

Honestly I'm amazed that even here on hackernews PHP gets so much hating over meaningless things.

I mean, hating PHP for copying Java OO model in 2004? Com'on... It's not like PHP ever wanted to be a fancy language.

EDIT: Apparently PHP5 was released in 2004, not 2003.

EDIT2: One thing PHP got right over Java: type-hinted parameters are not nullable by default. NullPointerException anyone?

Re: An Exceptional Change in PHP 7.0

#30
Amusingly, after months of pointless bikeshedding, we managed to convince the internals team to throw an exception during the extreme case of a CSPRNG failure.

https://www.sammyk.me/security-changes-to-the-php-7-csprng-i...

You can read my arguments on the mailing list, but basically it amounted to:

    $chars = 'abcdefghijklmnopqrstuvwxyz234567';
    for ($i = 0; $i 
If random_int() returned FALSE, $password would be the string 'aaaaaaaaaaaa' (and you'd have 12 E_WARNING errors in your log).

By making it an exception, random_int() will now fail closed (kill the script by default), but the developer can still handle it gracefully.

    $chars = 'abcdefghijklmnopqrstuvwxyz234567';
    try {
        for ($i = 0; $i template->kill('An unrecoverable fatal error occurred.');
    }
Or something similar.

Is it a BC break? Sure. Is it worth it? Oh yeah.

Post reply on HN