Live data from Hacker News

Why Developers Hate PHP

jesuisundev.com

51–60 of 114 posts

Re: Why Developers Hate PHP

#51
post #49

I will say this for PHP: Its interaction with my brain had such a nearly-disastrous impact on my life, that it finally allowed me to finally get the mental health treatment I'd been seeking for a decade, and to realize the fundamental and unfixable weakness of my marriage. ------------------------------------------------------- If you enjoy eating pad Thai, that is great for you. I do too. But different people are di…

There's an obvious difference between choosing not to use PHP and shitting on an entire language based on a decade's old idea of the language is.

The PHP project experience which cost me a job that I loved, nearly got me kicked out of my home, and prompted multiple evenings of suicidal ideation, and led my wife to be filled with anger at me even 7 months later is from the end of 2018.

I am responsible for how I manage my mental health. Part of exercising that responsibility is my firm choice I will never again work with PHP.

Re: Why Developers Hate PHP

#52
post #39

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

When someone gives you a long list of reasons why they hate something, why do you conclude they only hate it because it's trendy to hate it?

because this kind of rants are pointless, they are not bringing any value. Every language comes with their own inconsistencies or oddity. Most of those points raised are just added to a laundry list for its own sake, it's not something you come along every single day. You might have a WTF moment once in a while but that's something that happens with every language. I'm still not able to understand why everyone hate PHP and then at the same time love Javascript or Python or Ruby.

Re: Why Developers Hate PHP

#53
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?

Re: Why Developers Hate PHP

#54
post #14
post #4

Earlier quoted context omitted.

I didn't, skimmed. > PHP is the most widely used language in the world for websites. Being served does not equate to being used to develop new things. Is there really that many new websites, website features being authored in PHP? Sure there is maintenance work and some popular platforms are written in it. But beyond that? I haven't seen a job posting in long time.

I'm using it at a fresh start up. Having used node, internal Google frameworks, python, and dart previously, I would highly recommend PHP for new projects. Laravel is what makes it worth it imo.

Laravel is pretty sweet, I recently scoped it out (been in Flask land and itching to try some Elixir/Phoenix) and it's got everything, exploring the queues now. I really like the helpers for accessing array elements through dot notation. Example:

  $data = [
  'more' => [
      'complex' => ['my value']
   ]
  ];

  if (array_key_exists('more', $data) && array_key_exists('complex', $data['more']) && array_key_exists(0, $data['more']['complex'])) {
  echo $data['more']['complex'][0];
  }

You can do this:

  echo Arr::get($data, 'more.complex.0');

Plus the bog standard php null coalescing operator "??" is pretty sweet.

  // fetch the value of $_GET['user'] and returns 'not passed'
  // if username is not passed
  $username = $_GET['username'] ?? 'not passed';

Just some little things off the top of my head. *Formatting.

Re: Why Developers Hate PHP

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

Re: Why Developers Hate PHP

#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 it is the opposite of hype driven development

Does C# gets so much hate? Or Python? I don't think either of them is an example of hype driven development, and yet they are rather respected languages that don't get so much hate.

> Developers hate PHP because they believe the language has been stagnating for 20 years.

Again, I don't think that's it. I've been using PHP7 for the last few months and yes, it is different from PHP4. You have optional static typing, you have better tools, a lot has changed. Yet deep in its core the language is still badly designed. I constantly find some weird behaviours that just don't exist in other languages.

Example:

  $array = [1,2,3,4]
  array_filter($array, function($x) { return $x %2 === 0; });
In every other language I've used, such function would return [2,4], but not in PHP.

  array_merge(
    [ "a" => "w", "1" => "x" ],
    [ "a" => "y", "1" => "z" ]
  )
In every other language I know, it would return [ "a" => "y", "1" => "z" ], but PHP returns [ "a" => "y", 0 => "x", 1 => "z" ]

I know, these are just random examples and every language has its quirks. The problem is that in PHP there are so many quirks I keep checking how each function works, because after half a year I still can't remember them (and I don't remember whether array is a first or a second argument, because it depends on a function).

I wouldn't say that I hate PHP. It's another tool that I know and am able to use. I just think in 2020 in most cases when you start writing a new web application, there are plenty of better options. So maybe that's where the hate comes from? That there are simply many more consistent languages that just remain less popular than PHP?

Re: Why Developers Hate PHP

#57
I think there's something people miss when looking at PHP as a system - the fact that it's a collection of hot swappable logic modules (pages)

PHP pages themselves can download packages of additional PHP pages and extend functionality as the website runs. For example the user can install a message board from the UI in WordPress, and PHP files themselves will download additional PHP files needed for a message board, and boom your site now has a message board - no recompile, install, or deploy. Your running system has extended itself in real-time with additional functionality.

Maybe I'm crazy, but I think there is something special about this that our typical compile/deployed applications aren't designed for.

Before the web, applications tended to carry their state in memory, but with the web we stored state in the database. Our logic really only needs to take the request from the user and either pull or modify data from the database and return. A lot of web apps today feel hollow as we rarely store state in them, we just pull, manipulate, and render database data. What if each major code path was its own binary? That's kind of like what PHP is.

With PHP the application is almost living as it is never really turned off/on, just modified over time. If there's a bug in one page, I just need to fix that one page. And a single page is lightning fast to deploy to my servers. The rest of the system keeps humming.

Now the language itself might not be the best, but do you see how this system is fundamentally different from single binary web applications?

Re: Why Developers Hate PHP

#58

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

And she's right. Just the `fopen` example is bad enough. It's characteristic of the whole ecosystem. Python and others do not have issues like that.

It's a footgun waiting to happen as you switch between PHP and other languages.

Re: Why Developers Hate PHP

#59
PHP is my favorite language to write SQL injection vulnerabilities, just like C is my favorite language to write pointer bugs.

(Disclaimer - The last time I used PHP was over a decade ago, and the last time I used C was in college)

Re: Why Developers Hate PHP

#60
post #31
post #21

Earlier quoted context omitted.

They might think you expect them to dislike it. Also, maybe they fear if they say they like PHP you'll take points off.

That goes for any question in interviews. I expect honesty and I'm straightforward about it.

This is not really a question like any other, because it's a very polarizing one.

It's fair to intentionally ask polarizing questions if the objective is to find how if a candidate can take moderate positions in those contexts, but it's definitely not like "any question in interviews".

Post reply on HN