More on PHP’s “bad design”

In the previous post I was responding to PHP: a fractal of bad design, and I was talking about the main topic. Design that is. But the post also made me smile and shrug my shoulders many times, and I wanted to share why. I’m sorry, but I wasn’t able to find the author’s name anywhere on his site (speaking about design).

What amused me was that many of the discussed problems there are made up. For example, he is talking about this line of code:

@fopen (’', ‘r’);

He writes a whole thing about how it works, and presents every point in his list of things as a surprise. And my reaction is, yeah, that’s obvious for me that PHP would do that, so what exactly is wrong?

Or, he writes:

"6" == " 6", "4.2" == "4.20", and "133" == "0133" and adds “But note that 133 != 0133, because 0133 is octal.

He implies, I guess, that something about this is wrong or unpredictable, but he doesn’t say what, and I really have no idea. I mean, come on, you should know a language’s syntax to write programs in it, right?

Or he explains how global variables work:

Global variables need a global declaration before they can be used. [...] globals can’t even be read without an explicit declaration — PHP will quietly create a local with the same name, instead. I’m not aware of another language with similar scoping issues.

Not a word on what he thinks of as an issue. Isn’t it OK for languages to differ?

I’ve been programming in PHP for some ten years and for most of the things he talks about, it never even occured to me that it was a problem. Also, I didn’t know many of the things he wrote about, because to encounter them you have to be really sloppy. He deliberately writes some messy code (like five nested ?:’s or 2 < "foo") and then complains that PHP does not execute it the way he wanted.

If you don’t know the language really well, at least write a clear and readable code, and it will work fine.