PHP: A fractal of bad design
If this one thing that annoys me on HN it's the pervasive anti-PHP snobbery. A selection from the OP:<p>> Because of the @, the warning about the non-existent file won’t be printed.<p>So your complaint is that when you use @ to suppress an error it... suppresses the error?<p>> The language is full of global and implicit state.<p>"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).<p>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".<p>> There is no threading support whatsoever.<p>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.<p>> 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.<p>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?<p>> In, say, Python, the equivalent .index methods will raise an exception if the item isn’t found.<p>I, for one, <i>hate</i> throwing an exception when an item isn't found. This sucks:<p><pre><code>    try:
      index = a_list.index(a_value)
    except ValueError:
      # do something
</code></pre>
- 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<p>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 -.<p>> [] cannot slice; it only retrieves individual elements.<p>Much like Java/C/C++. PHP has array_slice() if you want it.<p>It's since been redacted but the OP originally claimed that Facebook doesn't really use PHP (because, hey, that fits his world view).<p>Look, I could go on but really what's the point? Haters gonna hate.<p>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 <i>none of that matters</i>. 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.<p>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.<p>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.<p>The procedural style is actually very natural for serving HTTP requests. The core of PHP is a <i>stateless</i> 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.<p><i>This is a feature not a problem</i>. 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.<p>I really don't understand this need to complain so vocally about something like this. Possible reasons:<p>- It affirms the OP's sense of superiority somehow;<p>- It's about "street cred" with [Python, Ruby, Node.js, insert other language here]; or<p>- One is so obsessed with "purity" that one spends all one's time complaining about how everything isn't Lisp.<p>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?<p>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.<p>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).