News for hackers. Stuff that matters.
Re:PHP: A fractal of bad design by cletus on Tuesday April 10, 2012 @09:44AM (#3822119)
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 just means it is request-scoped (ignoring $_SESSION, which is explicit anyway).

Do people complain about request-scoped data in any other language? No. The PHP haters just decide to hate this largely due to the (somewhat incorrect) label of "global".

> There is no threading support whatsoever.

That's a good thing. It forces you to use async HTTP programming or something like beanstalk, both of which are better than the complexity of threading.

> array_search, strpos, and similar functions return 0 if they find the needle at position zero, but false if they don’t find it at all.

So, it's a problem that array_search returns 0 when something is at... position 0? And returning false is just a sentinel value, much like functions in other languages might return -1. So what?

> In, say, Python, the equivalent .index methods will raise an exception if the item isn’t found.

I, for one, hate throwing an exception when an item isn't found. This sucks:

    try:
      index = a_list.index(a_value)
    except ValueError:
      # do something
- If you use FALSE as an index, or do much of anything with it except compare with ===, PHP will silently convert it to 0 for you

Yes, you have to use --- and basically understand that otherwise 0 == false. So what? In C/C++ you also have to remember to use == not -.

> [] cannot slice; it only retrieves individual elements.

Much like Java/C/C++. PHP has array_slice() if you want it.

It's since been redacted but the OP originally claimed that Facebook doesn't really use PHP (because, hey, that fits his world view).

Look, I could go on but really what's the point? Haters gonna hate.

Sure it would've been nice if PHP had been consistent with, say, parameter ordering (needle, haystack vs haystack, needle) and function naming (sometimes using underscore, sometimes not) but really none of that matters. If you use it, you soon remember. Humans are built to understand inconsistent languages. If we weren't, we wouldn't be able to speak to each other.

Some like to argue that PHP is a beginner's language. I disagree. I think PHP is a fine language for just throwing something together... if you know what you're doing. Otherwise it's just a recipe for SQL injection and XSS vulnerabilities.

A common mistake with PHP is people try and turn it into Java with complicated object frameworks. There is typically lots of hand-wringing about OO'ness.

The procedural style is actually very natural for serving HTTP requests. The core of PHP is a stateless core of API functions. This is incredibly useful for keeping resource usage down. Much like the old CGI model, the entire environment is created, used and destroyed on each request.

This is a feature not a problem. Anyone who has done Java Web development (with stateful servlets or any derivative) should know this as it is virtually impossible not to have come across resource leakage and concurrency issues at some point. The stateful model, while useful, has a significant cost.

I really don't understand this need to complain so vocally about something like this. Possible reasons:

- It affirms the OP's sense of superiority somehow;

- It's about "street cred" with [Python, Ruby, Node.js, insert other language here]; or

- One is so obsessed with "purity" that one spends all one's time complaining about how everything isn't Lisp.

Use it or not. I don't care. If you're not going to use it, why complain about it? If you are using it, what does the public snobbery (which is really adding nothing new to all the other PHP rants) really add?

I'm a big fan of pragmatism and the fact is that 4/20 of the most visited sites on the Internet are written in PHP.

EDIT: /sigh/ I get the inevitable "you must be a PHP programmer" retort (like that's actually a retort and not just more snobbery). For the record, I've only used PHP for ~6 months. My main experience is Java (~14 years), Python (~2 years), C (~5 years) and C++ (~4 years).

Re:PHP: A fractal of bad design by ceol on Tuesday April 10, 2012 @11:00AM (#3822443)
> 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 everything. Now your client/boss/friend is pissed because when someone submits their form and they have a space in their name, the entire site crashes, and you have to figure out what's causing it through a tangled web of spaghetti code with no errors.

This is the norm in PHP because, like the author said, it makes it incredibly easy to write bad code.

> If this one thing that annoys me on HN it's the pervasive anti-PHP snobbery.

This isn't anti-PHP snobbery. To write it off as such is an attempt to dismiss most of the (quite valid) complaints. And complaining about someone complaining is really only highlighting your own hypocrisy.

As you said, you really don't understand his need to complain. That's fine, but many on HN do. This was a great write-up for all of PHP's downfalls. Some of it is really only complaining about how PHP isn't Python, but there are a lot of fantastic points about language design and how PHP sacrifices consistency for... really no reason at all. So don't assume every complaint about a language is "snobbery" or an attempt at "streed cred" (wut?) Instead, ask yourself why there are so many people writing so many complaints about this one language. Then, ask yourself why you're writing them off.

Re:PHP: A fractal of bad design by pfraze on Tuesday April 10, 2012 @11:38AM (#3822668)
> This is the norm in PHP because, like the author said, it makes it incredibly easy to write bad code.

I do maintenance for a lot of PHP sites at my job, and the code is staggeringly difficult to debug or modify. It's punishment for my sins.

PHP was a tool for generating textual data structures (HTML) and it should've been leveraged by another tool for control flow and business logic, but it wasn't. The code I maintain is pre-frameworks; it's got no DRY, no separation of concerns, no design forethought at all. It's just HTML generation that satisfies its needs as they arise.

Now PHP is a quirky, mediocre, and capable language that's still really good at generating HTML.

Re:PHP: A fractal of bad design by hardy263 on Tuesday April 10, 2012 @11:29AM (#3822617)
> 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 disable. Although they won't suppress all errors like PHP does, it can still bite you if you don't fix them.

It IS snobbery. You're taking a look at other people's code, and judging the language from it. I've written PHP for about 3 years and I've never once used the @ to suppress errors.

Re:PHP: A fractal of bad design by ceol on Tuesday April 10, 2012 @01:21PM (#3823306)
> 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 by blackhole on Tuesday April 10, 2012 @03:00PM (#3823818)
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 by Retric on Tuesday April 10, 2012 @08:39PM (#3825297)
GC is not about preventing memory leaks, it's there to make managing memory easier not automatic. One of it's biggest advantages is the ability to deal with memory fragmentation which is ridiculously hard to do well in C++ style languages.
Re:PHP: A fractal of bad design by jsaunders on Tuesday April 10, 2012 @02:47PM (#3823752)
You can write bad code in any language. It's the programmers responsibility to make sure the stuff they are writing is good and that only comes from experience with the language.
Re:PHP: A fractal of bad design by PyErr_SetString on Tuesday April 10, 2012 @04:52PM (#3824369)
Of course you can. But is it always an equal share of bad code for each language? If not, then you have to admit that the language itself will encourage or discourage bad code or bad coders.
Re:PHP: A fractal of bad design by chaostheory on Tuesday April 10, 2012 @10:34PM (#3825653)
It's easier to write bad code in certain languages, as well as vice versa.
Re:PHP: A fractal of bad design by aGHz on Tuesday April 10, 2012 @12:24PM (#3822947)
The article tries to be a comprehensive list of problems with PHP and @ is a notorious one, even if you personally are disciplined enough to avoid it.

Not to mention that I have no idea why the original commenter picked on this. It was listed as one of the 7 or so things that can go wrong with that one single, not unusual line of code. It's not like he had a whole paragraph about why @ is bad.

Re:PHP: A fractal of bad design by maratd on Tuesday April 10, 2012 @12:42PM (#3823053)
> The article tries to be a comprehensive list of problems with PHP and @ is a notorious one

Nonsense. The @ error suppression is a tool, just like any other. It should be used sparingly, but it does have its uses. I have been writing in PHP for over a decade and I have used it exactly one time. And yes, it irritates me when I see it in other's code all over the place ... which is why I refactor all external PHP code before I place it inside of mine.

The amazing thing about PHP is that it has a plethora of tools available and the language doesn't force you to write code in some constrained manner according to what some snob perceives as the right way. The only right way is the way that works and works well.

You don't like a feature of PHP? Don't use that feature. Simple as that.

Re:PHP: A fractal of bad design by aGHz on Tuesday April 10, 2012 @01:05PM (#3823198)
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 teams. Of course it's not as simple as that. If I had a penny for every time I had to fix someone not checking that strpos() === FALSE, well, I could fund my own startup. 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.

Re:PHP: A fractal of bad design by maratd on Tuesday April 10, 2012 @02:10PM (#3823533)
> 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 refactor other peoples' code, but I refactor my own. That's the only way to get to a quality code base.

Re:PHP: A fractal of bad design by aGHz on Tuesday April 10, 2012 @03:13PM (#3823881)
> 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 by jurre on Wednesday April 11, 2012 @02:12AM (#3826197)
Isn't the fact that you have to refactor so much of other peoples code an indication that something might be wrong? I'm not familiar with the PHP ecosystem but I don't know of many people having to refactor Ruby gems.
Re:PHP: A fractal of bad design by jablan on Tuesday April 10, 2012 @02:42PM (#3823721)
> Other languages have some sort of warning suppression as well

But there is a huge difference here. PHP directly encourages it, making it so easy to do "just prefix it with @" and dedicating a part of the core language syntax to it (thus spending such a nice character for such a triviality). I believe (correct me if I'm wrong) that in Java, it is just another annotation, and in C# just another preprocessor directive.

And I think that's what the article is about - so many things are wrong in the very foundation of the language.

Re:PHP: A fractal of bad design by mbell on Tuesday April 10, 2012 @09:24PM (#3825459)
In Java annotations can be used to ignore compiler warnings, not runtime errors.

To get the same effect as @ you'd have to use try {} catch {} blocks all over the place and leave the catch blocks empty, as with any other language with runtime exceptions. Sadly this is done more that one would think...

Re:PHP: A fractal of bad design by jablan on Wednesday April 11, 2012 @04:17AM (#3826495)
But that was exactly my point. When you do it in Java, you are obviously doing something wrong (or at least not intended to be done). It just looks wrong at the first glance, with empty blocks and all. In PHP, it's just a single character prefix, no bother at all to add, and looks just like any other sigil. Its usage is definitely not discouraged by design, quite the contrary.
Re:PHP: A fractal of bad design by tjogin on Tuesday April 10, 2012 @02:16PM (#3823574)
> You've turned something that's a person's fault into something that's the language's fault.

PHP programmers have only one single thing in common. PHP.

Re:PHP: A fractal of bad design by Zarel on Tuesday April 10, 2012 @10:17PM (#3825610)
> I've written PHP for about 3 years and I've never once used the @ to suppress errors.

Is it so wrong to use @? I've always used (@$_REQUEST['foo'] === 'bar') as a shorter way of writing (isset($_REQUEST['foo']) && $_REQUEST['foo'] === 'bar') - I'm curious if there's a problem with that approach.

Re:PHP: A fractal of bad design by wvenable on Tuesday April 10, 2012 @11:51PM (#3825838)
Actually yes because the error gets generated anyway (and that is slow) and then it's just suppressed at the last moment.

You'd probably be better off creating a function to do what you want succinctly rather than using the suppression operator.

Re:PHP: A fractal of bad design by brendoncrawford on Thursday April 12, 2012 @05:59PM (#3834388)
You be using array_key_exists instead.
Re:PHP: A fractal of bad design by angersock on Tuesday April 10, 2012 @01:07PM (#3823213)
"You've turned something that's a person's fault into something that's the language's fault."

Out of curiosity, where do you side on the C-is-an-unsafe-evil-language-because-of-pointers debate?

Re:PHP: A fractal of bad design by smsm42 on Tuesday April 10, 2012 @12:27PM (#3822969)
"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 stuff, that's the point.

"This was a great write-up for all of PHP's downfalls."

These "downfalls" are known and discussed 1000 times. Really, who needs another article about "PHP sucks because I can find 3 functions with inconsistent parameters"? How exactly it is going to make anything better? What exactly does it contribute to the world?

Re:PHP: A fractal of bad design by ceol on Tuesday April 10, 2012 @01:11PM (#3823241)
> 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 metadata and class in the same file.

> These "downfalls" are known and discussed 1000 times.

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

Re:PHP: A fractal of bad design by smsm42 on Tuesday April 10, 2012 @01:28PM (#3823332)
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 by ceol on Tuesday April 10, 2012 @06:00PM (#3824684)
> How that even makes sense?

Maybe my point wasn't clear. It's not a difference in how those two ORMs accomplish their goal; it's that PHP doesn't let you do what SQLAlchemy does, even if you wanted to. Want to write an ORM that uses YAML, XML, or comment annotation in Python? Great! Want to write an ORM that uses classes or objects as column declaration in PHP? Too bad.

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

Now I think you're just being petty. Obviously an underscore isn't what we're talking about here. Take your straw man elsewhere, please.

Re:PHP: A fractal of bad design by wvenable on Tuesday April 10, 2012 @11:54PM (#3825841)
> Want to write an ORM that uses classes or objects as column declaration in PHP? Too bad.

I'm actually doing just that; it's not as clean as you can do in Python but it's not outrageously verbose either. Trying to map one languages features onto another is not a valid critique.

Re:PHP: A fractal of bad design by joesb on Wednesday April 11, 2012 @05:22PM (#3829719)
So PHP does not have the same power as Python, just like Java. Yet I don't see people saying Java encourage writing bad code.

Different language has different limitation. Just because you can not have SQLAlchemy in C, does not mean C encourage bad code.

Re:PHP: A fractal of bad design by Gigablah on Tuesday April 10, 2012 @08:31PM (#3825272)
> Want to write an ORM that uses classes or objects as column declaration in PHP?

What prevents you from doing that in PHP?

Re:PHP: A fractal of bad design by ceol on Tuesday April 10, 2012 @08:50PM (#3825345)
PHP doesn't allow you to pass functions and classes as arguments.
Re:PHP: A fractal of bad design by Gigablah on Tuesday April 10, 2012 @10:45PM (#3825675)
You can. Here's my code as an example:

https://github.com/gigablah/fsphinxphp/blob/master/src/FSphi...

Note the $getter parameter.

Re:PHP: A fractal of bad design by cgdangelo on Tuesday April 10, 2012 @09:20PM (#3825441)
Unless I'm misunderstanding you, passing functions as arguments is definitely possible with anonymous functions/closures.
Re:PHP: A fractal of bad design by smsm42 on Tuesday April 10, 2012 @07:06PM (#3824950)
I have no idea what you mean by "what SQLAlchemy does" - I'm sure it does lots of things and most of these are perfectly doable in any language out there. You must be meaning some specific thing that is a favorite of yours - and indeed maybe it is hard to do it in PHP (or maybe not - since you didn't tell what this thing is nobody can have any idea). Who cares? I can name a bunch of things that is harder to do in Python that in some other language, but I don't run around shouting "Python sucks".

> Now I think you're just being petty. Obviously an underscore isn't what we're talking about here. Take your straw man elsewhere, please.

What he's talking about here is known and talked about for 10 years. It's just function names, it's not that big a problem. Yes, we know old function names are inconsistent. No, we can't change them because that will break code. If that's what makes or breaks language for you, PHP is not for you, and most languages are not for you, because you're obviously not interesting in solving the problem, you're interesting in boosting your self-esteem by boasting shiniest tool out there. Nothing wrong with it, but PHP is not created for that. If that means for you that PHP sucks, fine, but for 99.99% out there shininess is very low on the list of priorities. So if you want to discuss important stuff, leave old stale stuff like ranting about strpos alone and discuss important stuff.

Re:PHP: A fractal of bad design by ceol on Tuesday April 10, 2012 @08:54PM (#3825359)
> I have no idea what you mean by "what SQLAlchemy does"

You must have missed the rest of that paragraph. I specified what it does.

> What he's talking about here is known and talked about for 10 years. It's just function names, it's not that big a problem.

Again, missing the point. Python has these same minor inconsistencies in its stdlib. It's the combination of all these minor inconsistencies with a language that gives you more tools to write bad code than good that makes PHP torturous. It's everything that the author wrote about in one neat little package.

Re:PHP: A fractal of bad design by fadzlan on Tuesday April 10, 2012 @04:49PM (#3824351)
Then again, why can't the author not post it on HIS blog? No less.

Any old tired issues for you could be something new for someone else.

Re:PHP: A fractal of bad design by smsm42 on Tuesday April 10, 2012 @07:07PM (#3824958)
That's fine, anybody is free to rant on his blog. That's just a rant and not some revelation about something significant about PHP.
Re:PHP: A fractal of bad design by rplnt on Tuesday April 10, 2012 @11:42AM (#3822683)
From the very (very) long article you picked somewhat weird collection to defend.

> So your complaint is that when you use @ to suppress an error it... suppresses the error?

This was one bullet-point from a 7-item list. Also it didn't say that @ is bad in any way (perhaps its use is), it was there only to demonstrate error configuration which is clear by the bullets after it.

> > There is no threading support whatsoever.

> That's a good thing.

You are right that for many tasks not even thinking about threads is a good idea, but there are cases where threads are very appropriate. Having the feature wouldn't hurt, would it? (Considering how tied the php is to C)

> So, it's a problem that array_search returns 0 when something is at... position 0? And returning false is just a sentinel value, much like functions in other languages might return -1. So what?

He explained the "so what" in the next few lines. I'll cite it for you: "If you use FALSE as an index, ..., PHP will silently convert it to 0 for you. Your program will not blow up; it will, instead, do the wrong thing with no warning"

Having a try statement is same as having to check for the value to be FALSE/-1/whatever, we can agree on that. But letting users write code that appears to work (yet it does not) is not a good property of a language.

> Much like Java/C/C++. PHP has array_slice() if you want it.

PHP's arrays are very different (uniform types) from those of C/C++/(Java?). So why compare them? Other than that, I agree, having slice function is enough. The author could've left this one out.

So two of your points were taken out of context, one was your opinion (two if we count your preference of if over try when checking for errors), and only two were probably justified. Rather strange choice considering you had dozens of options.

Re:PHP: A fractal of bad design by loganlinn on Tuesday April 10, 2012 @12:08PM (#3822857)
> But letting users write code that appears to work (yet it does not) is not a good property of a language.

I still don't see the point that's trying to be made here. Whether it returns -1, FALSE, or you need a try/catch, the programmer still needs to check. To successfully program in any language with an 'index of' function, a check needs to exist regardless...

Re:PHP: A fractal of bad design by TylerE on Tuesday April 10, 2012 @12:23PM (#3822937)
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.
Re:PHP: A fractal of bad design by maratd on Tuesday April 10, 2012 @12:49PM (#3823090)
> 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.

Re:PHP: A fractal of bad design by TylerE on Tuesday April 10, 2012 @01:26PM (#3823326)
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 by maratd on Tuesday April 10, 2012 @02:06PM (#3823519)
Yes, I know. Like I said, error_reporting on (set to E_STRICT) and display_errors off. And yes, where the error goes is a completely different question.
Re:PHP: A fractal of bad design by taytus on Tuesday April 10, 2012 @01:20PM (#3823300)
"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 by corford on Tuesday April 10, 2012 @03:23PM (#3823922)
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 by karolist on Tuesday April 10, 2012 @02:48PM (#3823757)
He specifically mentioned you should have errors logged instead, not displayed to the client. You're quoting only the part that leads to your insult.
Re:PHP: A fractal of bad design by maratd on Tuesday April 10, 2012 @02:04PM (#3823510)
I have and since I write the code, I expect zero errors. And that's what I get. When there are errors, that code needs to be fixed. Tell me more, bro.
Re:PHP: A fractal of bad design by angersock on Tuesday April 10, 2012 @01:15PM (#3823256)
"You should never have error reporting turned off."

Ha. Ha ha. Ha ha ha.

Tell me more about maintenance programming and legacy production systems.

Re:PHP: A fractal of bad design by scott_s on Tuesday April 10, 2012 @03:38PM (#3823999)
To make explicit the design problem: the "not found" sentinel is automatically converted to a valid index. That's dangerous.
Re:PHP: A fractal of bad design by rictic on Tuesday April 10, 2012 @02:24PM (#3823625)
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's not saying that you can't do awesome work in php, there's tons of great counterexamples. It's not saying that you can't change the world with php. It's not even saying that you can't write a maintainable, legible, beautiful app with php.

The problem with php is that the core language ignores a ton of what we as a community have learned about language design: Be consistent. Make it easy to do the right thing. Make unwise code look awkward. Pick a type system and embrace it. Don't try to magically do the right thing. Be predictable. Avoid action at a distance.

It's not that PHP makes for a great beginner language. So does Python. It's not that PHP has flaws, so does every language. Many darlings of the Hacker News crowd even have some of the flaws from this list. But I'd challenge you to make a list a quarter of the size of this one with Python, or Haskell, or frankly even Javascript.

Re:PHP: A fractal of bad design by sedev on Tuesday April 10, 2012 @02:52PM (#3823773)
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 by freshhawk on Tuesday April 10, 2012 @01:46PM (#3823421)
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 by obituary_latte on Tuesday April 10, 2012 @10:08AM (#3822215)
It seems that many people disregard the fact that PHP is a very accessible language to a programming newcomer. You can quickly and easily install LAMP or MAMP and in minutes have a working, dynamic web page (albeit local) along with a plethora of examples and tutorials. This is huge. This shows the newcomer that this mysterious code stuff is actually accessible; that they can create something that works. That's a nice intro to programming.

More programmers===better programs. How can this be a bad thing?

As far as the snobbery goes, to me it just seems like natural human behavior. People need to believe that their beliefs, their choices are the right ones. For some, the easiest way to do that--rather than being honestly objective or introspective--is to degrade what others do.

Re:PHP: A fractal of bad design by acdha on Tuesday April 10, 2012 @11:11AM (#3822517)
I agree with the general point but this seems more of an indictment of other languages than a plus for PHP: with PHP, it's easy to get started with the most simple features - and then it takes years to learn how to cope with the language quirks and inconsistencies, deal with outright bugs, and learn a number of non-obvious ways in which your “working” site might be hacked due to a hidden language feature.

There are two ways in which this could be dealt with: one would be for PHP to have a change of religion by the core developers and start a massive cleanup project fixing API warts, adding placeholders to or deprecating the default MySQL driver, etc. This wouldn't be easy but it wouldn't be especially difficult except that the core developers are usually hostile to suggestions that they fix, or even document, mistakes.

The other would be for other languages to start simplifying the learning process - Google AppEngine is probably the easiest intro of all, albeit with a severely non-standard architecture, Rails.app, etc.

I think a language like Python or Ruby is likely to gain a smooth dev server install before PHP becomes less treacherous.

(Pro-PHP flamers: I started using PHP back in 1999. Your arguments are not new.)

Re:PHP: A fractal of bad design by obituary_latte on Tuesday April 10, 2012 @11:52AM (#3822745)
Yes, that would be great. An alternative intro would be most welcome. It should, though:

- Be able to start and serve in minutes, across most platforms

- Allow for portable code e.g. the code you create locally should be able to be ported over to an actual webhost with only [S]FTP.

- Not require the command line to "work". At all.

I tried to learn django ~a year ago, and it was an experience wrought with frustration and pitfalls. The documentation was so-so, and limited in resources (or I couldn't find it). The main trouble was getting all the packages/dependencies correct. I am quite comfortable with linux and terminal (again thanks to PHP), and though I eventually got it working, I was turned off enough by the whole process that I didn't do anything with it. My accomplishment was that I got it to work, which for me was certainly still worthwhile as I was still learning, but a newcomer would likely have gone back to Facebooking long before that...

What is dangerous about the PHP bashing in my eyes (speaking with some current experience as a newb), is when someone decides to try and learn programming and they google some stuff about PHP and read endless diatribes on how horrible it is. So they go off and try django or RoR, are met with tough situations with little to no documentation; can't get anything to work, and give up all together.

Whether or not PHP is pretty, it is accessible. The divide that is created by language ideology only serves to hurt the community as a whole, IMO.

Re:PHP: A fractal of bad design by kijin on Tuesday April 10, 2012 @02:45PM (#3823735)
I would add low cost to that list.

HN's fascination with cloud computing and massive scalability is not representative of web dev in the rest of the boring world. The vast majority of web sites out there are powered by shared hosting, where the norm is to cram 1,000 sites on a cPanel server. Apache+PHP makes economic sense in this environment because when your site isn't getting any requests, it uses no resources. But if everybody started running a persistent Django or Rails process in the background, or if every customer had to be given a VPS, hardware and maintenance requirements would quickly exceed what the provider can profitably offer.

I can host a small website on NearlyFreeSpeech for $0.30 per month plus bandwidth, even less before they introduced a surcharge for dynamic websites. One of my old clients is hosted on another pay-as-you-go shared host, where she incurs all-inclusive charges of $0.07 per month on average. (The site is mostly static, with a PHP guestbook.) Like it or not, PHP makes this possible by folding the app server into the web server, and a lot of effort has gone into making such an environment reasonably secure without blowing up resource requirements. Even if you use a regular shared host that charges $8.95 per month, that's still cheaper than a medium-quality managed VPS.

The current state of shared hosting might not be anything to write home about, but the low cost (compared to a VPS) allows anybody, including dirt poor students, to run a web site without being held hostage to a less customizable service that might or might not exist tomorrow, e.g. Posterous. I think this contributes to technical literacy and independence in a small but unique way. Any realistic alternative to PHP had better meet the same requirements.

Re:PHP: A fractal of bad design by crag on Tuesday April 10, 2012 @02:15PM (#3823565)
"The main trouble was getting all the packages/dependencies correct. "

This is the one big problem python has; terrible package management. I can think of 3 different package management systems for python. All of them barley work and the various libraries all require different mangers and different python versions.

This package requires python 2.6. This other package requires 2.5. And now we have separate python 3.x packages. Ridiculous.

Re:PHP: A fractal of bad design by kijin on Tuesday April 10, 2012 @04:47PM (#3824340)
Well, to be fair, "package management" in PHP usually means bundling every single package you need with every single app that needs them. Then you upload the whole thing by FTP.
Re:PHP: A fractal of bad design by sedev on Tuesday April 10, 2012 @12:50PM (#3823098)
"(Pro-PHP flamers: I started using PHP back in 1999. Your arguments are not new.)"

See, that's part of the problem. PHP has been terrible for close to two decades. It used to be even worse than what Eevee describes.

Re:PHP: A fractal of bad design by Yen on Tuesday April 10, 2012 @05:09PM (#3824441)
Maybe I'm missing something in your comment here, but - Python and Ruby already have smooth dev server installs. In fact, much smoother than PHP, as you don't need apache or fancy permissions to just run something local.

Ruby, rails: "rails server" Ruby, sinatra: "ruby <sinatra script>" Python, django: "python manage.py runserver"

All of these spin up an app server on some port > 1024. I'm honestly not sure how it can get much easier than that.

Re:PHP: A fractal of bad design by acdha on Tuesday April 10, 2012 @08:41PM (#3825308)
Start as J. Random Noob: they need to install python, virtualenv, etc. before learning how to create a module, create multiple config files and so forth.

Technically PHP isn't much easier if you need to compile it, configure Apache, etc. but in practice they just pay $1/mo for a crappy hosted account where they simply upload a file and start fiddling.

This is a trivial distinction for a professional developer but there are quite a few PHP users who started with a personal homepage and grew from there – and despite the stereotype, they're not all designers, either. That's why I like the Rails.app idea: give today's bright 13-year-old a nice, easy path to getting something visible and let them get hooked before they need to learn all of this other stuff.

Re:PHP: A fractal of bad design by obituary_latte on Wednesday April 11, 2012 @07:44AM (#3827022)
Yeah, sorry I was unclear. In this case I was trying to get it working on a VPS.

The local stuff was indeed nice and simple.

Re:PHP: A fractal of bad design by pratyksp on Tuesday April 10, 2012 @02:12PM (#3823546)
Very low barrier to entry is also one of the reason why PHP ecosystem sucks. More than 95% of PHP programmers never grow up from beginner(at least what I've seen) even after more than few years of use. And those who grow up starts to use other language.

The PHP crowd is mostly filled with "Internet Programmers" [A person who copies code from the internet and pastes in one's codebase, without even reading it, and expects it to work.] And this also applies to all the javascript programmers who can download a jquery plugin and successfully use it in a website.

They even don't know that you can install PHP, apache and mysql separately and use it. For them XAMPP is all there it is, armed with dreamweaver and a ftp client. Most of them will be lost without cpanel.

I've tried teaching a few but all I get is :"go away don't try to be smart in front of me, I know what I'm doing."

Most of you here are smart people. But out there this is what you get from most of the PHP programmers.

Re:PHP: A fractal of bad design by jtc331 on Tuesday April 10, 2012 @03:36PM (#3823984)
Exactly. I don't actually agree that low barrier to entry is a good thing. Languages should be easy for people who've learned them, not necessarily easy for newbies.

That's the real idea with the principle of least surprise. It shouldn't surprise experts. But programming is hard. It's modeling real world processes in the abstract. That's hard. It isn't going to be simple for people who don't know how to program.

Re:PHP: A fractal of bad design by BCM43 on Tuesday April 10, 2012 @10:16AM (#3822240)
More programmers===better programs. How can this be a bad thing?

I'm not sure this is true. Going with the articles example, that's like saying "the more people who know how to use a hammer, the better houses we will have".

Re:PHP: A fractal of bad design by obituary_latte on Tuesday April 10, 2012 @10:19AM (#3822247)
OK, say there were only 2 people working on the (any open-source project). How do you think it would look today?

I think it pretty basic an assumption that the more eyes looking at something, the better the chances of finding (and fixing) mistakes as well as finding room for improvement.

Re:PHP: A fractal of bad design by TylerE on Tuesday April 10, 2012 @12:24PM (#3822949)
It's true in the sense that giving everyone desktop publishing software in the early 90s led to lots of beautiful typography and well thought-out layouts.
Re:PHP: A fractal of bad design by TorbjornLunde on Wednesday April 11, 2012 @07:27AM (#3826946)
I assume that you are being ironic, and you’re right: there was a lot of ugly graphic design in the 90s. This is partially due to the whole grunge-trend…

However: I think today we have more beautiful design that we would have had if the design tools had not become democratized, maybe not in percentage, but certainly in amount.

My speculation: programming --> more programs. Both crap and great ones.

Re:PHP: A fractal of bad design by smokinjoe on Tuesday April 10, 2012 @10:56AM (#3822416)
No, but the more kids who have exposure to an easy-to-get-started language will result in more kids that are actually really into it getting that early start they need.
Re:PHP: A fractal of bad design by smsm42 on Tuesday April 10, 2012 @12:29PM (#3822980)
Are you claiming less people should have access to programming? Should we have a guild with mandatory 10-year apprenticeship in Haskell?
Re:PHP: A fractal of bad design by prodigal_erik on Wednesday April 11, 2012 @04:45AM (#3826561)
That's kind of over the top, but I'd like to see everyone spend their first six months in any language that doesn't hide your mistakes from you by quietly guessing what you might have wanted and doing something random.
Re:PHP: A fractal of bad design by joesb on Wednesday April 11, 2012 @05:24PM (#3829726)
Less people should have access to computer, it will make those who does more competent at programming.
Re:PHP: A fractal of bad design by jablan on Tuesday April 10, 2012 @03:06PM (#3823840)
> 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 by slantyyz on Tuesday April 10, 2012 @08:36PM (#3825286)
>> Here where I live, about 80% of webdev jobs are PHP.

I'm getting the impression that this is why a lot of people hate PHP - Money. People don't like that the market is full of money wasted on an inferior language. Perhaps there's a bit of envy in that, perhaps not.

The winners in the marketplace aren't always the best, and it's not easy to change minds. People get religious about the things that make their living, whether it be a programming language, certification/designation or some other thing.

But Atheists aren't going to convert many Christians and Christians aren't going to convert many Scientologists.

In the end, you have to work within the parameters of the market or create your own. I guess for some people, like the OP, it's easier to vent. Nothing wrong with that - we should all speak our minds, but it's not necessarily going to be effective in converting anyone.

Look at the resulting discussion here, the OP's either preaching to the choir, or his message is falling on deaf ears. I don't see a lot of 'a-ha, he's right, I'm switching now' posts.

Re:PHP: A fractal of bad design by anthonyb on Tuesday April 10, 2012 @09:56PM (#3825548)
People hate PHP because it's an incredibly stupid and frustrating language to use, and most of the people who use it don't know anything else. The money comes from them fucking things up, and their boss having to call in people who know what they're doing to fix it (aka. hack it back into some semblance of "working"). The amount of waste that goes on in most PHP shops is what irks me - use the right tool, spend at least 50% less time working around stupid quirks.

> the OP's either preaching to the choir, or his message is falling on deaf ears.

That was the point of the post. If he points people to it, and they read it but still disagree that PHP is crap, then there's obviously no hope for them.

Re:PHP: A fractal of bad design by slantyyz on Tuesday April 10, 2012 @11:04PM (#3825730)
>>The amount of waste that goes on in most PHP shops is what irks me - use the right tool, spend at least 50% less time working around stupid quirks.

Yeah, but why would you care unless you're begrudgingly participating in the PHP industry? It's not your problem unless you make it your problem - i.e., if you're so against it, don't work in a PHP shop, don't take PHP contracts. Problem solved - if other people want to use lame/bad languages, who cares?

The impression I'm getting is that a segment people who hate on PHP are participating in the PHP economy because there aren't as many local opportunities in {insert language here}. To me, that's not much different from the guy who's stuck working in a "lowly" coffee shop because he can't find a job in his field of study, which of course, makes him entitled to be rude to customers and his fellow employees.

Re:PHP: A fractal of bad design by nupark2 on Wednesday April 11, 2012 @01:34AM (#3826095)
Even those of us entirely outside the PHP economy (mobile, desktop, big-iron server) occasionally stumble into a monster of a mess that some PHP idiot left behind, and have to clean it up (usually by just replacing it outright, because PHP isn't worth maintaining).

The money is nice, but after watching the ridiculous waste of PHP idiocy for the Nth time, you can't help but want to get people to stop.

Re:PHP: A fractal of bad design by anthonyb on Wednesday April 11, 2012 @02:09AM (#3826183)
And that's not counting all of the messes that are inflicted on you as a user of PHP - security holes and password breaches or having to interface with some crappy API to get stuff done.

At least with PHP it's likely to be some vaguely HTTP/POST-ish interface, not some XML/WSDL monstrosity...

Re:PHP: A fractal of bad design by jablan on Wednesday April 11, 2012 @04:26AM (#3826514)
No, it's not the money. It's comfort, and the opportunity for less compromises when picking jobs. I want to be able to choose between three Ruby/Python/whatever shops and pick one with the coolest people and coolest projects, rather than having one Ruby/Python and two PHP shops to choose from.

And, unlike you, I don't think these articles are pointless. I hope they help PHP get more bad reputation among coders, and peer pressure will do the rest.

Re:PHP: A fractal of bad design by slantyyz on Wednesday April 11, 2012 @11:39AM (#3828023)
To paraphrase something Neil DeGrasse Tyson said to Richard Dawkins: If you want to change someone's opinion about something, you need to be sensitive to the state of mind of the person you're trying to convince.

Bashing and negativity is not the way to do it.

You'll get much farther showing a PHP person something more interesting (whether it be Rails, Django, or whatever) and highlighting all the cool things about it. Because that person will not be on the defensive, his/her mind will be way more likely to have that 'Wow, that's so cool I should try it' moment.

Re:PHP: A fractal of bad design by Sapient on Tuesday April 10, 2012 @11:49AM (#3822728)
> Some like to argue that PHP is a beginner's language. I disagree. I think PHP is a fine language for just throwing something together... if you know what you're doing. Otherwise it's just a recipe for SQL injection and XSS vulnerabilities.

I could not agree with you more. Advising beginner programmers to use PHP is like handing out guns in a playground, someone is going to get hurt, and it will probably be the users.

Re:PHP: A fractal of bad design by vital101 on Tuesday April 10, 2012 @09:48AM (#3822131)
> There is no threading support whatsoever. >> That's a good thing. It forces you to use async HTTP programming or something like beanstalk, both of which are better than the complexity of threading.

While there isn't multi-threading in PHP, you can in fact multi-process which provides similar functionality.

http://php.net/manual/en/function.pcntl-fork.php

Re:PHP: A fractal of bad design by encoderer on Tuesday April 10, 2012 @02:10PM (#3823534)
While there aren't many cases where you should run PHP as a daemon or cron job, there are _some_. Like, for example, you've got dozens of models and helpers written in PHP and you want to use them in queue workers or aggregation jobs.

I've run into these a few times and acquired a bit of mastery of PHP's PCNTL, POSIX and Semaphore/SHM/IPC extensions.

I don't do much PHP work anymore, but I do maintain an OSS library for other people in that situation: PHP Simple Daemon -- https://github.com/shaneharter/PHP-Daemon

This is half-plug, half +2 to your point.

Re:PHP: A fractal of bad design by BasDirks on Tuesday April 10, 2012 @11:15AM (#3822545)
Your main "defense" of PHP's flaws consists of saying "other languages suck similarly". Well congratulations, PHP is apparently a "worst-of" of programming idioms. I like me some caviar with my programmes.
Re:PHP: A fractal of bad design by RyanMcGreal on Tuesday April 10, 2012 @10:29AM (#3822293)
> 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
Re:PHP: A fractal of bad design by anthonyb on Tuesday April 10, 2012 @09:48PM (#3825521)
Why would you do that? You're going to have to have a branch to deal with the -1 further down in your code anyway. Why not just deal with it when it happens:

  if value not in list:
      # value not found
      return
  index = list.index(value)
  # Code to deal with the thing
Re:PHP: A fractal of bad design by ge0rg on Tuesday April 10, 2012 @01:50PM (#3823439)
There is even a built-in for that:

    >>> "foo".find("a")
    -1
Re:PHP: A fractal of bad design by andreasvc on Tuesday April 10, 2012 @06:48PM (#3824892)
No there isn't. The one you cite is for strings, not lists. I've always wondered why lists shouldn't also have find, rindex or replace methods.
Re:PHP: A fractal of bad design by zerostar07 on Tuesday April 10, 2012 @06:58PM (#3824922)
I 'm glad this got topvoted.

PHP is the MS Word of web programming. It will be here for a long time, just get over yourselves and concentrate on what you write, not how you write it.

Re:PHP: A fractal of bad design by pippy on Tuesday April 10, 2012 @06:03PM (#3824697)
Plus if you to take a step back, and look at the fundamentals of PHP:

* PHP is open source. If you don't like it, change it. Or submit patches. Or bug reports

* PHP does what is says on the can. It's a hypertext preprocessor, and it does this exceedingly well

* If you're having difficulty doing complex work in PHP, you're using it for the wrong problem

The anti-PHP stance on HN is almost meme like. The lack of silly memes is why I respect HN over other aggregators,

Re:PHP: A fractal of bad design by rictic on Thursday April 12, 2012 @01:56PM (#3833479)
Part of the objection raised here is that the php maintainers are not amenable to fixing these problems with the language. Maintaining a private fork of the language with different semantics is both a recipe for disaster and at best a local solution.

Bug reports have been filed and closed for many of these issues.

A full on fork of php might be interesting, though the thought of what's going on behind the scenes in the php interpreter terrifies me.

Re:PHP: A fractal of bad design by mainguy on Tuesday April 10, 2012 @06:37PM (#3824841)
Almost like posting something about a beowulf cluster of something on Slashdot a few years ago...

That having been said, I agree PHP does what it was designed to do, but has been leveraged into pretending to be a general purpose language (much like what happened with perl)... which it is NOT really good for.

Re:PHP: A fractal of bad design by qeorge on Tuesday April 10, 2012 @03:32PM (#3823964)
I agree with everything you've said, but most especially: "Use it or not. I don't care."
Re:PHP: A fractal of bad design by guccimane on Tuesday April 10, 2012 @10:13AM (#3822224)
> If this one thing that annoys me on HN it's the pervasive anti-PHP snobbery.

If there's one thing that annoys me on programmer forums in general, it's that pointing out PHP's giant flaws is conflated with snobbery. Design matters, and that is not the same thing as saying it's impossible to build anything good with PHP.

Re:PHP: A fractal of bad design by smsm42 on Tuesday April 10, 2012 @12:30PM (#3822993)
Pointing out "giant" flaws which don't really matter and can't be fixed for 1000th time is very useful for... remind me please, what exactly purpose?
Re:PHP: A fractal of bad design by nicholas_tuzzio on Tuesday April 10, 2012 @12:45PM (#3823068)
Convincing people to stop using such a flawed language when there are so many viable (and in nearly all ways preferable) alternatives.
Re:PHP: A fractal of bad design by smsm42 on Tuesday April 10, 2012 @01:10PM (#3823230)
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 write another "PHP sucks" article, that will do it.
Re:PHP: A fractal of bad design by jtc331 on Tuesday April 10, 2012 @03:29PM (#3823950)
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 by smsm42 on Tuesday April 10, 2012 @06:56PM (#3824911)
People who disagree are "programmars" just fine. They just know how to use proper tools for the job given, instead of ranting because they're too lazy to read the manual, like author of the post.
Re:PHP: A fractal of bad design by yusefnapora on Tuesday April 10, 2012 @08:36PM (#3825288)
Did the author give you the impression that he was "too lazy to read the manual?" I got almost the exact opposite impression, that he had read the documentation to the point of exhaustion and found it severely lacking.
Re:PHP: A fractal of bad design by mmj48 on Tuesday April 10, 2012 @02:52PM (#3823771)
> It can't be that intelligent people can disagree with you on what is important and what is not in a language.

This is quite harsh sarcasm, but if it isn't true for the GP, it's true for so many people. Well said.

Re:PHP: A fractal of bad design by fadzlan on Tuesday April 10, 2012 @04:55PM (#3824380)
I'd like to know how much of his massive complaint "don't really matter".

Programming language critic come up every now and then in HN, this is nothing new. If you got a point, why not refute it?

Are you saying language design don't matter and not worth discussing?

Re:PHP: A fractal of bad design by guccimane on Tuesday April 10, 2012 @12:45PM (#3823072)
Oh, you mean as opposed to the usefulness of calling people snobs because they understand that PHP is terribly designed? Fuck outta here.
Re:PHP: A fractal of bad design by smsm42 on Tuesday April 10, 2012 @01:18PM (#3823275)
There are a lot of snobs out there. It is a sad fact, regardless of that article. PHP snobbery is hugely widespread and 99.9% of people disparaging PHP are completely ignorant in PHP and don't bother to spend a minute even on reading the PHP manual - which answers 99% of things they complain about as being hard to understand (and try using Python without reading any manuals at all - see how far you go). I'm not saying PHP is perfect - it is not. I am saying if you take time to write a long article about PHP deficiencies while refusing to take 10 seconds to look up a thing in the docs - it doesn't look good.

PHP has some wrong design decisions, however many of them don't really matter (like function called strpos instead of str_pos - really, that's your problem?). Some do, and people are welcome to propose solutions for them. People also welcome to write rants about "PHP sucks, nobody should use it, anybody who uses it is an idiot" but they shouldn't expect this will be taken seriously.

Re:PHP: A fractal of bad design by anthonyb on Tuesday April 10, 2012 @09:42PM (#3825508)
> if you take time to write a long article about PHP deficiencies while refusing to take 10 seconds to look up a thing in the docs - it doesn't look good.

When did the original article ever suggest that? I got the impression that he had looked it up in the docs, and found the docs seriously broken. That fits my recollection of PHP's docs - there are a lot of them, but they often don't tell you what you need to know, so you have to go trawl through the comments. Of course, most of the code in the comments is crap, full of errors, has security holes or all three.

> function called strpos instead of str_pos - really, that's your problem?

Yes, that's a problem. Ditto for arguments in random order. It means that it's much harder to remember the function without having the docs open in another window.

"PHP sucks, nobody should use it, anybody who uses it is an idiot"? Sounds about right. I know people who are security consultants, who've worked with PHP for years and years - I even know a guy who works at Wordpress. None of them think that you should be using PHP...

Re:PHP: A fractal of bad design by maratd on Tuesday April 10, 2012 @12:51PM (#3823112)
You don't like it? Don't use it. You're the kind of asshole that'll walk up to somebody in McDonalds and tell them that the food they're eating isn't healthy. You know what? Mind your own business.
Re:PHP: A fractal of bad design by rictic on Tuesday April 10, 2012 @02:36PM (#3823683)
No, this is more like writing a long, well reasoned, extensively researched article with the thesis "McDonalds food is unhealthy". It is a public good.

No one in this comment section is saying to you "stop using php on this project you're doing because it's badly designed". No one is in your business.

Re:PHP: A fractal of bad design by jtc331 on Tuesday April 10, 2012 @03:32PM (#3823965)
The thing is we need to stop advising people to use it in the first place. That's what we're advocating.

That is, we're not telling people to stop after they've gone into McDonalds, we're decrying the fact that so-called health experts are telling people that McDonalds is actually just fine for you. That's a better analogy.

Re:PHP: A fractal of bad design by maratd on Tuesday April 10, 2012 @04:17PM (#3824187)
> The thing is we need to stop advising people to use it in the first place. That's what we're advocating.

Who are you to advocate that? Or to advocate anything?

I despise people who presume to know what's in the best interest of others. You only know what's in your best interest. You have no idea what is good for anyone else.

You want to share your experience? Great. Do it when it's asked for. Nobody asked for a hit piece on PHP.

> we're decrying the fact that so-called health experts are telling people that McDonalds is actually just fine for you.

Exactly which maven and luminary of computer science has advocated the use of PHP?

That is outright nonsense. At no point has that happened. PHP grew organically, without a single endorsement.

Re:PHP: A fractal of bad design by reinhardt on Tuesday April 10, 2012 @06:46PM (#3824887)
"I despise people who presume to know what's in the best interest of others. You only know what's in your best interest. You have no idea what is good for anyone else."

Wow. Are you seriously advocating the equivalent of moral relativism in programming? You have no idea if, say, Brainfuck is good for anyone else?

Re:PHP: A fractal of bad design by jtc331 on Thursday April 12, 2012 @01:49PM (#3833452)
"Exactly which maven and luminary of computer science has advocated the use of PHP?"

I didn't say that they were luminaries per se. Programmers telling non-programmers that PHP is OK for them is what I'm referring to. That would match the analogy--someone who's studying health science telling someone who hasn't studied health science that McDonalds is perfectly healthy.

Programmers need to stop telling non-programmers that it's perfectly OK to use PHP. Frankly, they need to be blunt that programming is hard. That you either have to willing to put in the investment or don't do it at all. This soft runway into developing applications is exactly the reason why so much poor software exists in the common market.

Re:PHP: A fractal of bad design by white_devil on Tuesday April 10, 2012 @10:06AM (#3822200)
Sooo.. You mainly use PHP yourself, then?
Re:PHP: A fractal of bad design by zackzackzack on Tuesday April 10, 2012 @10:16AM (#3822235)
Read his profile and you will see Java, Python, and C and he works at Google.
Re:PHP: A fractal of bad design by white_devil on Tuesday April 10, 2012 @12:24PM (#3822950)
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 try to skirt around the issues).

The human ego is a sad thing.

(Disagree? How about commenting instead of downvoting with self-righteous indignation?)

Re:PHP: A fractal of bad design by billpatrianakos on Tuesday April 10, 2012 @01:13PM (#3823244)
(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 acceptable but flaws in PHP are never acceptable.

A lot of people who "point out PHP's shortcomings" are really just on a mission to make themselves and their preferences superior. It's a big pissing contest and these arguments come and go like how JavaScript was once despised and now loved.

Re:PHP: A fractal of bad design by nupark2 on Wednesday April 11, 2012 @01:36AM (#3826099)
It's easier for PHP developers to write it off as "a pissing contest" than to face the cold hard truth: PHP is, objectively, awful. There is literally no reason to choose it over today's alternatives other than market inertia, which is exactly what articles like this one are trying to stop.