Live data from Hacker News

Why Developers Hate PHP

jesuisundev.com

61–70 of 114 posts

Re: Why Developers Hate PHP

#61
post #5

I know it's cool to hate PHP but I can think of other languages (Perl, VB6, Groovy) I dislike more. For a language to be so hated it has to be used a lot, and that's the primary virtue of PHP: it runs damn-near everywhere. Not only web scripting/apps but you can use it for shell scripting, Lambda/Azure Functions... there are even frameworks for creating native mobile applications with PHP. And I wouldn't be surprised…

Yeah, I think that goes back to something the OP said, which is that it's a victim of its own success. It's old enough that everyone has had a bad experience with it. I've had many that are directly or indirectly tied to PHP - my college blog was a hodgepodge of unmaintainable PHP scripts, I've run Wordpress blogs with plugins that broke in horrible and confusing ways, some things like argument order and operator precedence are confusing.

Combine with a long-enough life to have some famous bugs (like the hash collision DOS attack), and you have a recipe for widespread derision.

But it kept getting better. I work in PHP at my day job, and I enjoy it. Tools like PhpStorm and Phan make the experience excellent. If PHP 7.4 were launched today as "AWSLang", a stateless object-oriented optionally-typed scripting language that seems designed for working with Lambda functions, we'd love it. "You mean it just dies at the end of the request by default? No shared mutable state between requests? How functional!" Sure, we'd have a few things to complain about. But don't we always?

Re: Why Developers Hate PHP

#62
I'm a PHP developer and I really don't like this language. Right now it's paying my bills but I hope my next job won't be related to it. People are saying that PHP has become better and that's very true. But still far behind modern languages like Go, Python, Rust, Elixir. PHP is full of inconsistency, legacy code, and missing features. Core developers are doing great by adding a lot of new stuff and optimizations, but caring too much about backward combability disturbs the language from becoming better IMO.

Re: Why Developers Hate PHP

#63
post #42

Earlier quoted context omitted.

pick a random language, ruby, python, javascript etc etc and you'll find similar rants/complaints. Yet I think right now it's cool to shoot on PHP therefore everyone is more vocal

Yet I think right now it's cool to shoot on PHP This is not a recent thing, it has always been cool to mock PHP. It's not entirely unwarranted, but most programming languages have their own warts. For example, for some reason, creators of dynamic languages think they need to mess with variable declaration, to make it more accessible, or whatever, instead of staying with tried and true lexcially-scoped block-level var…

I don't know if that has to do with dynamic languages. Elixir reduced the scope of variables so that, for example, you must export it out of if statements, which irritates devs coming from most languages but which I think is a fantastic feature.

Re: Why Developers Hate PHP

#64
post #56

> Developers hate PHP because you are more likely to get errors with a language that allows so much freedom. Ruby gives you much more freedom than PHP. You can reopen classes, you can use any kind of object as a key in an associative array, you can write code that will execute when the class (not the instance) is being created. And yet I find it much easier to write stable code in Ruby. > Developers hate PHP because…

php > $array = [1,2,3,4]; php > var_dump(array_filter($array, function($x) { return $x %2 === 0; })); php shell code:1: array(2) { [1] => int(2) [3] => int(4) }

what's the problem with array_filter then? That keys are not reindexed?

Re: Why Developers Hate PHP

#65
post #47
post #17

> Most developers who hate PHP hate it out of elitism or ignorance. Either way it’s dumb. You have to choose a technology based on what you need. PHP is highly useful and powerful in many scenarios. And taking it out of the equation just because of its reputation is not a good idea. When I conduct hiring interviews, one of the questions I like to ask regardless of the language for the position, is the developer opini…

PHP always struck me as a language that had very haphazard beginnings and initial design considerations that continue to cause it problems, but less so as time goes one, that has made mostly good and well thought out decisions since then (and possibly because of that). The base language functions are a train wreck of multiple functions doing similar things that could easily be handled through a few slightly more flex…

You're right. And if you told me anything along those lines during an interview I would smile wide open knowing you speak from experience and not from prejudice.

Re: Why Developers Hate PHP

#66

https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ is a classic of this genre.

pick a random language, ruby, python, javascript etc etc and you'll find similar rants/complaints. Yet I think right now it's cool to shoot on PHP therefore everyone is more vocal

> pick a random language, ruby, python, javascript etc etc and you'll find similar rants/complaints

Yes, but that's not the point - the primary trait of "old PHP" (I don't know the "new PHP") is that it has not been designed.

Languages like Ruby, Python, etc. may have been designed, in a better or worse way, but there's a radical difference with a language that hasn't been designed at all.

Re: Why Developers Hate PHP

#67
post #23
post #20

There is no web framework out there which comes with such elegant concepts, syntax and feature-richness like Laravel. I have seen them all - Laravel is incredibly good, especially for small - mid sized projects! And this statement comes from a python guy.

Why do you prefer it over say, Flask or Django?

[deleted]

Re: Why Developers Hate PHP

#68
post #17

> Most developers who hate PHP hate it out of elitism or ignorance. Either way it’s dumb. You have to choose a technology based on what you need. PHP is highly useful and powerful in many scenarios. And taking it out of the equation just because of its reputation is not a good idea. When I conduct hiring interviews, one of the questions I like to ask regardless of the language for the position, is the developer opini…

its fun to trash talk PHP who cares if statements are accurate. PHP sucks because of the dollar signs everywhere. From a distance Wordpress code looks like Nigerian Prince emails. And crazy coding conventions like mysql_real_escape_string. Really PHP?

> From a distance Wordpress code looks like Nigerian Prince emails. And crazy coding conventions like mysql_real_escape_string. Really PHP

This is good stuff. And correct. I'd love to hear that during an interview. Although mysql_real_escape_string() is not really used anymore nor condoned last I checked.

> PHP sucks because of the dollar signs everywhere

Now this is just an opinion. No bueno my friend.

Re: Why Developers Hate PHP

#69
post #17

> Most developers who hate PHP hate it out of elitism or ignorance. Either way it’s dumb. You have to choose a technology based on what you need. PHP is highly useful and powerful in many scenarios. And taking it out of the equation just because of its reputation is not a good idea. When I conduct hiring interviews, one of the questions I like to ask regardless of the language for the position, is the developer opini…

Did PHP ever decide whether NULL < -1 or NULL == 0? I want to hire people who care about correctness, and insanity like that really should bother them.

null == 0 is true.

null === 0 is false.

false == 0 is true.

false === 0 is false.

null == false is true.

null === false is false.

null < -1 is true.

Re: Why Developers Hate PHP

#70
> Most developers who hate PHP hate it out of elitism or ignorance.

I don't think I'm an elitist. I inherited a system that was written by a pretty bright guy without a lot of programming experience: thousand-line files mixing logic and presentation, that sort of thing. It was a bear to maintain, it was a bear and a half to secure. It gave me a distaste for PHP, yes.

I don't hate PHP, I'd just rather use something else.

Post reply on HN