Live data from Hacker News

PHP: A fractal of bad design

me.veekun.com

391–400 of 514 posts

Re: PHP: A fractal of bad design

#391
post #381
post #264

If this one thing that annoys me on HN it's the pervasive anti-PHP snobbery. A selection from the OP: > Because of the @, the warning about the non-existent file won’t be printed. So your complaint is that when you use @ to suppress an error it... suppresses the error? > The language is full of global and implicit state. "Global" is one of those dogmatic points. Nothing is truly "global" in PHP. The "global" in PHP j…

It isn't just snobbery (though I'm not denying that there's going to be an element of that in the comments, languages make people get religious and weird). Being called in to do maintenance on a php project sends a stab of dread through the heart of an experienced programmer and it's worth understanding why. This article goes a long way towards doing so. It's important to re-iterate what the article is NOT saying. It…

For the record, the back of "Javascript: The Good Parts" actually has that. It has "The Bad Parts" and "The Awful Parts," in which Crockford goes into more detail with each error than Eevee does, and I believe it's still shorter than Eevee's blog post.

Re: PHP: A fractal of bad design

#392
post #362

Earlier quoted context omitted.

> Can you imagine, then, diving into a website's back-end to see @ all over? It turns out, the previous developer realized all those nasty notices and errors stopped happening if he slapped a @ on everything. You've turned something that's a person's fault into something that's the language's fault. Other languages have some sort of warning suppression as well, like Java's @SuppressWarnings or C#'s #pragma warning di…

> You've turned something that's a person's fault into something that's the language's fault. > You're taking a look at other people's code, and judging the language from it. At some point, you have to start blaming the language for fostering an environment where that code is acceptable.

Meanwhile, people still manage to write memory leaks in garbage collected languages specifically designed to not leak memory.

Re: PHP: A fractal of bad design

#393
300+ comments... seriously?

PHP is a language with problems like all others (c, java, python, etc). It can be used for good or for bad like any other programing language. All the problems on the article are well known by decent programmers.

PHP is out there, use if you want.

Go write decent code... stop nagging.

Re: PHP: A fractal of bad design

#394
post #264

If this one thing that annoys me on HN it's the pervasive anti-PHP snobbery. A selection from the OP: > Because of the @, the warning about the non-existent file won’t be printed. So your complaint is that when you use @ to suppress an error it... suppresses the error? > The language is full of global and implicit state. "Global" is one of those dogmatic points. Nothing is truly "global" in PHP. The "global" in PHP j…

> If you're not going to use it, why complain about it?

I can tell you my reasons: the market. Not all of us can roll a globe, close our eyes, pinpoint a place and tomorrow have a job there. Here where I live, about 80% of webdev jobs are PHP. Even when I do manage to get a Ruby or a Python job, chances are that I will be doing lots of PHP code maintenance and migration anyway. I would like to change it, and I don't know better than to advocate, pro and against.

Re: PHP: A fractal of bad design

#395
post #373
post #348

Earlier quoted context omitted.

Ok, let me fix that: "The article tries to be a comprehensive list of problems with PHP and @ is an error suppression tool that is notorious for being misused throughout the community". > I refactor all external PHP code before I place it inside of mine > You don't like a feature of PHP? Don't use that feature. Simple as that. I don't know anything about you, but judging from that attitude you haven't worked in many…

> I don't know anything about you, but judging from that attitude you haven't worked in many teams. I haven't worked on any teams. I've always written software solo. What of it? > You may have the luxury of refactoring all over the place, but the reality out there is that horrible code like this is left to fester until it causes real business damage. Refactoring is not a luxury, but a necessity. Not only do I refacto…

> I haven't worked on any teams. I've always written software solo. What of it?

Well, that means you have zero experience with the majority of concerns expressed in this thread, and so are not qualified to opine on them. You work in a happy bubble and I envy you for it, but in the real world you very very rarely get the go-ahead to refactor old code. So in the real world, you very very rarely get to see a quality code base. In any language, really, but PHP compounds this problem with its idiosyncrasies. But you wouldn't know about that.

Re: PHP: A fractal of bad design

#396
post #19

"(And strictly speaking, Facebook isn’t written in PHP; it’s written in a C++ macro language with a striking resemblance.)" I'm a Facebook engineer who works on the HipHop compiler and HipHop virtual machine. It's in PHP, absolutely full stop. It's amazing how much the fact that g++ is involved somewhere in the toolchain confuses people in this matter. C++ is just an intermediate representation; the source language r…

Hm, I'll admit I've spread a bit of misinformation on that matter myself, thanks for the correction. The source for my confusion (and I suspect others as well) was some comments around the time hip hop was made public that it basically wasn't worth using unless you were willing to put in a significant effort to write your php according to some strict guidelines. That made me peg it as something akin to pypy's rpython.

Re: PHP: A fractal of bad design

#397
post #361
post #344

Earlier quoted context omitted.

> have error reporting turned off (which you should) No, you should not. You should never have error reporting turned off. You should certainly have it set to not display errors to the client, but all errors should be sent to a log, preferably syslog, and they should be reviewed. Your code shouldn't generate any errors.

"You should never have error reporting turned of" Sorry bro, if you have ever put code on production with error reporting on...you are doing it wrong.

Are you insane?

In production, you should have error_reporting set to something like: E_ALL & ~E_DEPRECATED

And then:

display_errors = Off display_startup_errors = Off track_errors = Off html_errors = Off ignore_repeated_errors = Off ignore_repeated_source = Off log_errors = On error_log = /path/to/log/file (or syslog)

Re: PHP: A fractal of bad design

#398
post #354

Earlier quoted context omitted.

Convincing people to stop using such a flawed language when there are so many viable (and in nearly all ways preferable) alternatives.

Obviously, since millions of people are using it it is preferable for them. Of course, this is only because they are too stupid to agree with you and have the exactly the same criteria and preferences that you have. It can't be that intelligent people can disagree with you on what is important and what is not in a language. It's clearly either you didn't explain it to them or they're too stupid to understand. Let's w…

It's just that the people who disagree generally aren't really programmars, they're designers turned quasi-web-developers. The community does them a disservice by pointing them at a giant pile of crap and saying "Go use this. You'll be fine."

Re: PHP: A fractal of bad design

#399
post #354

Earlier quoted context omitted.

Convincing people to stop using such a flawed language when there are so many viable (and in nearly all ways preferable) alternatives.

Obviously, since millions of people are using it it is preferable for them. Of course, this is only because they are too stupid to agree with you and have the exactly the same criteria and preferences that you have. It can't be that intelligent people can disagree with you on what is important and what is not in a language. It's clearly either you didn't explain it to them or they're too stupid to understand. Let's w…

[deleted]

Re: PHP: A fractal of bad design

#400
post #264

If this one thing that annoys me on HN it's the pervasive anti-PHP snobbery. A selection from the OP: > Because of the @, the warning about the non-existent file won’t be printed. So your complaint is that when you use @ to suppress an error it... suppresses the error? > The language is full of global and implicit state. "Global" is one of those dogmatic points. Nothing is truly "global" in PHP. The "global" in PHP j…

I agree with everything you've said, but most especially: "Use it or not. I don't care."
Post reply on HN