Live data from Hacker News

Why Developers Hate PHP

jesuisundev.com

91–100 of 114 posts

Re: Why Developers Hate PHP

#91
post #69

Earlier quoted context omitted.

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.

are you sure null < -1 is true? If it's the case what happens to 0 < -1?

Re: Why Developers Hate PHP

#92
post #85
post #69

Earlier quoted context omitted.

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.

Like in JavaScript, just don't use ==. It's broken but you don't have to use it. In C you can write i[t] instead of t[i], but don't do it. I guess it's true for many languages. These funny features don't prevent you from writing good code, especially if you enforce some coding styles that will catch any unintended use of these features. Blame PHP for what you can't do with it, or for things you don't like but are for…

> In C you can write i[t] instead of t[i], but don't do it.

I had to check this myself. I'm astonished.

Re: Why Developers Hate PHP

#94
post #73

Earlier quoted context omitted.

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".

Fair enough. It's not comparable to just any question. But hear me, you have to poke the bee's nest with some polarizing questions to really know what's inside otherwise you're stuck hiring an unknown until it's too late and costly (for both parties) to find out they were not a good match.

I'm not saying don't ask it. If anything it can reveal personality issues like any question. Just saying as a statistic it's not reliable. :P

Re: Why Developers Hate PHP

#95
I'm still not entirely sure why, in plain 2020, PHP seems to be the only language missing a debugger able to run in a shell.

Python, Ruby, Javascript and others have a "debugger;" statement of some sort that, when hit by the execution flow, will pause the code and let you type stuff in your shell, letting you inspect the code, step forward, etc...

Why does PHP need me to configure an entire IDE or my browser? (I'm looking at you, xdebug). Why can't it have a cli-debugger?

Re: Why Developers Hate PHP

#96
post #85

Earlier quoted context omitted.

Like in JavaScript, just don't use ==. It's broken but you don't have to use it. In C you can write i[t] instead of t[i], but don't do it. I guess it's true for many languages. These funny features don't prevent you from writing good code, especially if you enforce some coding styles that will catch any unintended use of these features. Blame PHP for what you can't do with it, or for things you don't like but are for…

> In C you can write i[t] instead of t[i], but don't do it. I had to check this myself. I'm astonished.

C array access syntax is just syntactic sugar for pointer arithmetic. The array decays to a pointer so `t[i]` is interpreted as:

    *(t + i)
So you can see how swapping that around to `i[t]` is effectively the same operation:

    *(i + t)

Re: Why Developers Hate PHP

#97
post #69

Earlier quoted context omitted.

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.

are you sure null < -1 is true? If it's the case what happens to 0 < -1?

Well, -1 is just 0x…FFFFF, right? So any number is lesser than -1. I rest my case.

Re: Why Developers Hate PHP

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

I suspect the dollar signs may be part of the reason of PHP's success. While it's clear for experienced programmers that "x" and "y" are variables and "foo" is a function in "x = foo(y)", for new programmers "$x = foo($y)" is probably easier to read and mentally parse.

That is my personal experience anyway, as someone whose first truly serious language was PHP 20 years ago. Maybe it was just because I was used to it (BASIC also used $), but it took me a bit to get used to the "bare" variables in Python and C back in the day.

Re: Why Developers Hate PHP

#99
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 has its pros and cons. A big pro is definitively job security: learn it now, learn it well and you'll have work for quite a long time. Composer is a pretty sane package manager, there are tons of frameworks and libraries out there to do nearly anything you can imagine, and also it's surprisingly fast. I'll even forgive the operator weirdness-- one big pain point that remains for me is how debugging PHP code is done.

That said, after dealing with JavaScript and its inane ecosystem has made me appreciate all the ways in which PHP has improved over the years, although that's probably not the kind of answer you'd be looking for. :P

Re: Why Developers Hate PHP

#100
The article is correct in stating that PHP has moved quite a bit in the last ~10 years; even back when I was using PHP in the 5.1/5.2/5.3 days things were already steadily improving.

But ... that doesn't mean that PHP is a good language, or that people hate in PHP "just because it's cool". There are still many issues that remain. For example the very loose typing checking remains an issue and source of real bugs; e.g. a while ago a SAML library could be bypassed because it forgot to add the flag to in_array() to enable strict comparisons.

Much of the problems in PHP are with the standard library, and this is not easy to fix. Even the mysql deprecation (in favour of mysqli/PDO) took ages. I wrote a thing looking at fopen() in PHP a while ago, and I think it's a good example of the problems that remain in PHP: https://www.arp242.net/php-fopen-is-broken.html

There are still many issues with the standard library like this which are clumsy and just plain design errors, and many of them are too fundamental to work around or fix. Has PHP evolved? Sure, and that's great! But that doesn't mean it's now an especially good language. In general, I'd rather have a poor language with a good standard library than a good language with a poor standard library.

Aside: one weird thing about PHP's stdlib is that it's all written in C; I don't know any other comparable language where all of the standard library is written in C. I think this seriously hamper's the evolution of PHP's stdlib to a more modern experience.

There is no easy fix for any of this btw, because a revamping of the stdlib would likely lead to a "Python 3 scenario", so I don't blame the PHP devs for not fixing it (although I do blame them for introducing new flawed parts to the stdlib, like the whole DateTime fiasco), but that doesn't mean it's not a problem.

Post reply on HN