Live data from Hacker News

These are things in PHP which make me sad

phpsadness.com

31–40 of 217 posts

Re: These are things in PHP which make me sad

#31
post #10

Earlier quoted context omitted.

there's something wrong with the == and coercion in the if() statement in any language. making the switch in if() be a boolean only pushes the problem off to the programmer, who will often choose the wrong function or expression to do the conversion

> making the switch in if() be a boolean only What exactly is the alternative? If there's any problem here it's automatic coercion.

in statically typed languages like Java, C#, Scala and C++ people are always screwing this up

most languages have some screwed-uppedness about collections, both intrinsic to the language and that gets introduced by people who make APIs that aren't well designed. for instance, arrays and Lists are often not quite perfectly uniform (and it's often a thoughtless arbitrary choice if people decide to return you one or the other) Scala introduces it's own collections that provide more confusion when you're working with Java. The .NET framework has a great implementation of generics (makes Java and Scala look like a joke) but there are still many legacy APIs in the .NET framework that use non-generic collections.

One result is that it's not always obvious what the right way to test for "empty" is. One of the worst of them is that pretty frequently APIs will give you a null when they ought to be sending you an empty collection, so you need to check for null.

Re: These are things in PHP which make me sad

#32
post #20
post #18

The ridiculously terrible behavior of == is what makes me the saddest. http://www.php.net/manual/en/types.comparisons.php We then have === which does what == is really supposed to do, but even that still sometimes does the Wrong Thing.

Wow, a downvote within 30 seconds of posting? "php" == 0 returns true, and this makes sense how?

Because the string is first converted to an integer.

"==" makes the comparison after converting types (see: Type Juggling in the docs) where "===" requires that the types be the same in order to be equal.

Kind of weird the first time you see it, but it's a language design choice and does make sense once you understand it.

Re: These are things in PHP which make me sad

#33
post #25
post #14

Earlier quoted context omitted.

This should disappear soon[1], it seems the patch has been accepted (or is on a good way to be), according the internals@ mailing list[2]. [1] https://wiki.php.net/rfc/improved-parser-error-message [2] http://news.php.net/php.internals/52436

I'm actually surprised it's still there. I remember WTFing at that about four years ago.

I think pretty much every single PHP developers feels like you ^^.

Re: These are things in PHP which make me sad

#34
post #20
post #18

The ridiculously terrible behavior of == is what makes me the saddest. http://www.php.net/manual/en/types.comparisons.php We then have === which does what == is really supposed to do, but even that still sometimes does the Wrong Thing.

Wow, a downvote within 30 seconds of posting? "php" == 0 returns true, and this makes sense how?

It doesn't make sense unless you understand how PHP works - at which point you'd use ===.

Re: These are things in PHP which make me sad

#35
post #22

I've definitely run into #1 on the list. "Paamayim Nekudotayim" is a transliterated version of פעמיים נקודתיים‎, which means "double colon" in Hebrew. Zeev and Andi are Israeli, which kind of explains it, but the error message is still pretty useless.

Its only a "bug" because there's an unspoken rule that all programming languages should be written in English, and English doesn't have a proper word for this symbol. Pretend that English had no representation of an ellipsis, but Hebrew did. Should the language author say "Expected: dot-dot-dot" in the error message to appease native English speakers, or should (s)he use the unambiguous form?

In this case, the Hebrew word literally is T_DOUBLE_COLON, so not much is gained by its use. Perhaps reporting an "unexpected scope resolution operator" error would be better.

Re: These are things in PHP which make me sad

#36
post #20
post #18

The ridiculously terrible behavior of == is what makes me the saddest. http://www.php.net/manual/en/types.comparisons.php We then have === which does what == is really supposed to do, but even that still sometimes does the Wrong Thing.

Wow, a downvote within 30 seconds of posting? "php" == 0 returns true, and this makes sense how?

[deleted]

Re: These are things in PHP which make me sad

#37
post #22

I've definitely run into #1 on the list. "Paamayim Nekudotayim" is a transliterated version of פעמיים נקודתיים‎, which means "double colon" in Hebrew. Zeev and Andi are Israeli, which kind of explains it, but the error message is still pretty useless.

Its only a "bug" because there's an unspoken rule that all programming languages should be written in English, and English doesn't have a proper word for this symbol. Pretend that English had no representation of an ellipsis, but Hebrew did. Should the language author say "Expected: dot-dot-dot" in the error message to appease native English speakers, or should (s)he use the unambiguous form?

Pretend that English had no representation of an ellipsis, but Hebrew did. Should the language author say "Expected: dot-dot-dot"

Yes. It's not about appeasement, it's about consistency.

Re: These are things in PHP which make me sad

#38
post #20
post #18

The ridiculously terrible behavior of == is what makes me the saddest. http://www.php.net/manual/en/types.comparisons.php We then have === which does what == is really supposed to do, but even that still sometimes does the Wrong Thing.

Wow, a downvote within 30 seconds of posting? "php" == 0 returns true, and this makes sense how?

It makes sense for the same reason it makes sense in Perl: use a string as a number and you get the number that is at the start of the string. E.g., "12" == 12, and "12php" == 12.

Re: These are things in PHP which make me sad

#39

What makes me sad is that people will defend this horrible language to the death, regardless of how many problems there are with it. I don't get it; we know how bad PHP is, so why do people fight so hard? Oh, and to demonstrate: "PHP has no native Unicode type, no native Unicode handling, and cannot treat Unicode strings as strings." This true statement, composed of three observations about deficiencies in the langua…

> "PHP has no native Unicode type, no native Unicode handling, and cannot treat Unicode strings as strings." ... gets me flamed every time I mention it. Why?

perhaps because statement of of fact (``PHP has pluggable Unicode support'') beats wrong statement of oppinion (``PHP is bad because has no support for it''). It's borderline trolling to insist PHP does not, when people have been using it successfully in production for years now.

http://pl2.php.net/manual/en/book.mbstring.php in case your google is broken.

Re: These are things in PHP which make me sad

#40
post #32
post #20

Earlier quoted context omitted.

Wow, a downvote within 30 seconds of posting? "php" == 0 returns true, and this makes sense how?

Because the string is first converted to an integer. "==" makes the comparison after converting types (see: Type Juggling in the docs) where "===" requires that the types be the same in order to be equal. Kind of weird the first time you see it, but it's a language design choice and does make sense once you understand it.

I think the reason people object to this behavior, even when they do understand it is that it makes the obvious default (==) dangerous. It's especially dangerous in the hands of the sort of non-experts for whom it's intended to make life easier.
Post reply on HN