Live data from Hacker News

An Exceptional Change in PHP 7.0

daveyshafik.com

31–40 of 53 posts

Re: An Exceptional Change in PHP 7.0

#31

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.

Yeah, and also: Who gives a shit? It's the convention they chose, just adapt to it and get over it, or program in a different language.

People who like to complain about PHP are rarely the same people who use it every day.

Re: An Exceptional Change in PHP 7.0

#32

Earlier quoted context omitted.

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?

Just because a language is used to write bad code doesn't mean the language design itself is bad.

Re: An Exceptional Change in PHP 7.0

#33
post #27

Earlier quoted context omitted.

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.

Rationale was discussed on IRC, see:

https://wiki.php.net/_media/rfc/php.ns.txt

Linked to at the bottom of:

https://wiki.php.net/rfc/namespaceseparator

Re: An Exceptional Change in PHP 7.0

#35
post #32

Earlier quoted context omitted.

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

Just because a language is used to write bad code doesn't mean the language design itself is bad.

Exactly. I've seen beautifully written Java and I've seen (and written) ugly Java. The language syntax is by far the least contributing factor to the 'prettiness' of the code. With the exception of BF. :)

Re: An Exceptional Change in PHP 7.0

#36

Why does everything start with a backlash? I do not get this language at all.

The namespace separator in PHP is \. It seems like a horrible idea at first, but in practice the only place you ever see it is at the top of files:

    use Psr\Log\NullLogger;
    use Psr\Log\LoggerInterface;
    use Psr\Log\LogLevel;
…and then the rest of the code just uses NullLogger, LoggerInterface and LogLevel.

Re: An Exceptional Change in PHP 7.0

#37

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.

The reality is that the parser is absolute shit and that sort of necessitated the character not being '.'

But you get used to that kind of stuff writing PHP. At least Facebook is making things better.

Re: An Exceptional Change in PHP 7.0

#38
post #27

Earlier quoted context omitted.

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

Rationale was discussed on IRC, see: https://wiki.php.net/_media/rfc/php.ns.txt Linked to at the bottom of: https://wiki.php.net/rfc/namespaceseparator

I skimmed through it but couldn't really understand why they couldn't coopt one of the existing operators (for example, by making classes have a namespace for their methods)

Couldn't they provide a clearer explanation than simply dumping a huge IRC log like that??

Re: An Exceptional Change in PHP 7.0

#39
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.

Yeah I really miss the good old days of PHP3.

/s

Zend has made a lot of good decisions (and a few painful but livable bad ones) over the last decade.

Re: An Exceptional Change in PHP 7.0

#40
post #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.

The logic behind the difference is in the fact that PHP doesn't have assertions - the naming is based on the root cause, not when the occur.

A RuntimeException is something like "Database connection failed." A LogicException is an implementation issue (e.g. usually requires a code change to fix).

Post reply on HN