Ask HN: Why do people hate PHP so much?
1–10 of 25 posts
Re: Ask HN: Why do people hate PHP so much?
#2> An array in PHP is actually an ordered map.
Re: Ask HN: Why do people hate PHP so much?
#3One of the good things about PHP is that it has a very low barrier to entry, making it easy for people to get up and running.
I think, though, that that sometimes leads to one reason why people dislike it: a company gets up and running (which is a good thing) on a hideous pile of crap codebase (not so good) and then decides to hire some more serious developers.
I've been in that position, and it is not fun.
Re: Ask HN: Why do people hate PHP so much?
#4Re: Ask HN: Why do people hate PHP so much?
#5Failed closures that lack proper scoping, while they have been improved the underlying problem remains.
Continuation on inconsistency is that functions are not first class even though the syntax is the same for closures:
function foo () { } $foo = function () { } Inconsistency; Cannot access functions (closures) directly from arrays.
$list["something"] = function () { };
$list["something"]() What is "truthy" and what is "falsy", not unique to PHP but that doesn't mean PHP should do it.
Assumptions such as how it interprets numbers in octal
Functions do not follow any specific naming standard, i.e. some array functions are prefixed by array_*, some are not.
Include and require scoping is messed up as anything that is not a variable is mashed into the global scope.
Lastly in my post but far from all issues with PHP; A crap-load of legacy because "we can never break anything"
Re: Ask HN: Why do people hate PHP so much?
#6I'd suggest reading PHP: a fractal of bad design http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/
Re: Ask HN: Why do people hate PHP so much?
#7I'd say the second problem is the most objectively bad. It is very easy to write PHP code that exposes you to all kinds of known exploit classes like SQL injection, command injection, cross-site scripting, etc. The language seems to encourage poor practices like building query strings directly from remote input without the use of a true query builder.
PHP also has a problem that it shares with JavaScript and to a lesser extent Java -- the quality of the user base and user-contributed code is often very poor. If you look for PHP code on StackOverflow or Reddit or similar sites, you are likely to get something that is horribly wrong, comically inefficient, or whose use will immediately introduce a dangerous remote security vulnerability. This comes from the simple fact that it's often a beginner language, so you have a lot of inexperienced people participating in forums and contributing sample code.
Re: Ask HN: Why do people hate PHP so much?
#8Inconsistency, very prone to security mistakes, poor type system, and some people just find its syntax "ugly." For example lots of folks hate $strings and $_WTF['bbq'] type syntax. Perl is another language whose syntax draws a lot of haters. I'd say the second problem is the most objectively bad. It is very easy to write PHP code that exposes you to all kinds of known exploit classes like SQL injection, command injec…
I won't entirely disagree with you on this, because there is still a ton of that code out there, but PHP has had true 'query builders' for a while now, and the mysql_ functions are being deprecated anyway.
Re: Ask HN: Why do people hate PHP so much?
#9Re: Ask HN: Why do people hate PHP so much?
#10Inconsistency, very prone to security mistakes, poor type system, and some people just find its syntax "ugly." For example lots of folks hate $strings and $_WTF['bbq'] type syntax. Perl is another language whose syntax draws a lot of haters. I'd say the second problem is the most objectively bad. It is very easy to write PHP code that exposes you to all kinds of known exploit classes like SQL injection, command injec…
>The language seems to encourage poor practices like building query strings directly from remote input without the use of a true query builder. I won't entirely disagree with you on this, because there is still a ton of that code out there, but PHP has had true 'query builders' for a while now, and the mysql_ functions are being deprecated anyway.
One thing I learned from NodeJS is that the quality of the community around a language can matter more than the language. JavaScript is a crap language, but the NodeJS community and the base of available modules is just so good that it makes up for a lot of the language's faults. When I tried it out I thought "who says you can't polish a turd?" I mean... Joyent and Node's community have buffed that thing down to gleaming crystal.
In counterpoint -- Java's actually a pretty good language, but its community's addiction to criminal overengineering is a big reason it hasn't been "sexy" in some time.