14 ms·
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 fi
by cletus 15y ago
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).
- vital101 15y ago> 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 http://php.net/manual/en/function.pcntl-fork.php
- encoderer 15y agoWhile 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 https://github.com/shaneharter/PHP-Daemon This is half-plug, half +2 to your point.
- white_devil 15y agoSooo.. You mainly use PHP yourself, then?
- zackzackzack 15y agoRead his profile and you will see Java, Python, and C and he works at Google.
- white_devil 15y agoMore 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?)