Live data from Hacker News

PHP: A fractal of bad design

me.veekun.com

361–370 of 514 posts

Re: PHP: A fractal of bad design

#361
post #344
post #330

Earlier quoted context omitted.

In PHP, if you forget the check, and have error reporting turned off (which you should), you'd never KNOW you forgot the check, because missing it is only a logic error, whereas an exception blowing up a python script will be caught by the runtime.

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

Re: PHP: A fractal of bad design

#362
post #293

Earlier quoted context omitted.

> So your complaint is that when you use @ to suppress an error it... suppresses the error? From your edit, you've only been working with PHP for about 6 months, so you may not have seen some of the code most others have. 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 eve…

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

Re: PHP: A fractal of bad design

#363

Earlier quoted context omitted.

I agree with you and I'm really surprised in 15 years, or how over old PHP is, THERE IS NOT ONE SINGLE ALTERNATIVE!! Why? For PHP I sign up for one of the million LAMP ISPs, I upload a .php file with .php embedded in HTML and I'm done. Where's the Ruby version of this? The Python version? The JavaScript version? The Perl version? THEY DON'T EXIST. You wanna use Perl or Python. You either have to use slow slow cgi or…

> Where's the Ruby version of this? The Python version? The JavaScript version? heroku ? you don't even have to upload anything manually, a single command deploys your app.

man, you can use pagodabox and go from dev to prod with one line of code as well.

Re: PHP: A fractal of bad design

#364
post #344
post #330

Earlier quoted context omitted.

In PHP, if you forget the check, and have error reporting turned off (which you should), you'd never KNOW you forgot the check, because missing it is only a logic error, whereas an exception blowing up a python script will be caught by the runtime.

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

I'm just calling it what php.ini calls it.

The settings related to displayed errors in the page are error_reporting and display_errors. The error logging is a totally sperate group of keys starting with log_

Re: PHP: A fractal of bad design

#365
post #355
post #334

Earlier quoted context omitted.

"This is the norm in PHP because, like the author said, it makes it incredibly easy to write bad code." PHP makes it extremely easy to write ANY code. But since article saying "I've noticed this piece of good code in PHP" is not going to get on HN anytime soon, you get much more attention to bad one. That's like saying Internet is the source of filth because it makes easy to post bad stuff. It makes easy to post all…

> PHP makes it extremely easy to write ANY code. No. PHP makes it easy to write bad code and between normal and challenging to write normal code. This is why Doctrine , the closest thing PHP developers have to SQLAlchemy, needs three ways to declare table and column metadata: a separate YAML file, a separate XML file, and in PHP comments. All three of those methods are awful, and only one allows you to keep the metad…

And again you make the same mistake. You take one solution, you say it doesn't work like your favorite solution (while obviously all proper solutions should be done exactly like the one you prefer, since there's only one right way to do anything and it's, not surprisingly, exactly the way you prefer) and you make it the fault of the language used for it's implementation. How that even makes sense?

I write code in a number of languages, and there's nothing "challenging" in writing proper code in PHP. The fact that your example has nothing to do with code quality or language only underlines that.

> "And, like a wiki, it's useful to have them all in one place."

Maybe, but that article isn't it. PHP has a wiki: http://wiki.php.net/. You want to list things you want fixed in PHP and have it in one place? Ask for an account and maintain a page there. Rehashing old tired "strpos doesn't have underscore and str_rot13 has, oh noes!!! I can't use language with missing underscore!!!" is really stale by now and doesn't contribute anything new.

Re: PHP: A fractal of bad design

#366
post #42

I'm going to be unfair and quote just two words from the article: > empowered amateur PHP is a gateway drug to web development. And that's awesome. With almost every other popular web development language I've heard of[1], there's this grey area between "my app works on my local machine" and "my app works on the server" that is really hard to grok as a beginner. There's a reason entire businesses are built on the ide…

I find it odd how many people keep saying it's that simple to push PHP code to a box and get it working. Sure, if you've got crazy simple requirements it's generally a cinch. Once you do anything remotely non-trivial (want to read from a file? use some third party library, handle errors in a consistent manner) then you start hitting into issues with file permissions, PHP version differences, modules not compiled in b…

For all the "script kiddies" writing PHP they don't have to setup a server. Sign up for a $5 a month LAMP web hosting site. Done.

Even those that do run their own server many linux installations have options to install the AMP part of LAMP by default. Again, nothing to do

Re: PHP: A fractal of bad design

#367
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…

So you disagree strongly. Fine. I happen to totally agree, but that's not an argument I'm going to get in to to since it never gets anywhere.

I am confused by why you think this is "anti-PHP snobbery". What about HN's attitude to cold fusion or to VB? How can you tell which criticism is valid criticism from experienced developers about which tools are good and which are bad and which is "snobbery"?

It's not like experienced developers who dislike PHP for being poorly designed and having a poorly managed community is a rarity. It's very common among respected developers. I suppose that to be a respected developer you must conform to the anti-PHP bias? Does the conspiracy go all the way to the top?

Or maybe a lot of these criticisms are valid, but you disagree for your own specific reasons?

Re: PHP: A fractal of bad design

#368
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, for one, hate throwing an exception when an item isn't found. This sucks: You can always do: index = a_list.index(a_value) if a_value in a_list else -1

There is even a built-in for that:

    >>> "foo".find("a")
    -1

Re: PHP: A fractal of bad design

#369
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…

"It's in PHP, absolutely full stop"

Well, you're the authority, but is that really a fair assessment? Has HipHop diverged from PHP enough to really still be considered PHP?

Re: PHP: A fractal of bad design

#370

Earlier quoted context omitted.

More than half of the top level comments are from people who use PHP. You can tell by how they rush into PHP's defense and try to argue against the article. The original post just can't be sensibly called "anti-PHP snobbery". It just points out PHP's shortcomings. But when all these PHP-users can't really attack the truth, they attack how it's presented instead (and of course whip up some strawmen and generally just…

(I didn't downvote first off) PHP devs certainly know its shortcomings like JS guys know that languages too. It's not the fact that he points out the shortcomings, that's fine. What makes it snobbery is how the author points out flaws and is so passionately anti-PHP with the subtext being "what I use is superior". He points out flaws in his preferences but in a way that makes it seem like flaws in Python are acceptab…

> What makes it snobbery is how the author points out flaws and is so passionately anti-PHP with the subtext being "what I use is superior"

Not sure about the sentiment being present in the post, but what he uses most likely is superior - it's quite challenging not to.

> makes it seem like flaws in Python are acceptable but flaws in PHP are never acceptable

Flaws in Python are acceptable - or at least relatively easy to tolerate - because it's such a lovely, lovely language and environment in general. Flaws in PHP are on a whole other level.

> people who "point out PHP's shortcomings" are really just on a mission to make themselves and their preferences superior

Projecting some kind of superiority or an air of Being Right (when others are wrong) is an element in practically all comments on the Internet. Including ours here. Posting online is all just mental masturbation, pretty much. We just can't resist the temptation.

That aside, if someone's preference is Python, it's obviously a superior preference to PHP.

(Yes, Python is my preference. That doesn't change the way things are.)

Post reply on HN