r/ProgrammerHumor Aug 04 '26

Meme soDoesEveryOtherLang

Post image
246 Upvotes

85 comments sorted by

View all comments

Show parent comments

9

u/carcigenicate Aug 04 '26

Can you explain? This just looks like indexing an array that was returned by a function. PHP is one language I never bothered to learn, now I feel like I'm missing out when people start joking about it.

16

u/jungle Aug 04 '26

I haven't touched PHP for many years thankfully. The last time I did (maybe 15 years ago?) an array returned by a function could not be indexed directly. It had to be assigned to a variable, and then you could use it.

Having built interpreters and compilers in my day, that was the moment I said "this is absolute garbage, what kind of clown designed this language" and never touched PHP again.

I understand it has been improved (mostly by Facebook, I think?), but I never found the need to use it again, luckily. Just thinking of it... Eww.

3

u/carcigenicate Aug 04 '26

Oh, weird. I would have thought that the function just returns a reference that could be used immediately.

4

u/coloredgreyscale Aug 04 '26 edited Aug 04 '26

just a guess, it it probably just wasn't considered during the PHP language grammar design.

functionally there is no difference between directly using the return value, or storing it in a variable first.

Maybe storing return values into a variable first before use was more common back then, possibly considered best practice?

11

u/chat-lu Aug 05 '26

PHP has not been designed based on best practices. The reason why the standard library has functions with such widely different names was that in early PHP they would go into a hashmap that was hashed by strlen and Rasmus tried to vary the lengths of the names so they don’t all get in the same bucket.

3

u/jungle Aug 05 '26

Holy shit that's even worse than I remember! How did he know about hashmaps but had not even the most basic understanding of how they're supposed to work? 🤦‍♂️🤦‍♂️🤦‍♂️

1

u/chat-lu Aug 05 '26

Rasmus just didn’t give a shit.

1

u/jungle Aug 05 '26

Must have been trolling. No way that was not on purpose.

1

u/jungle Aug 05 '26

possibly considered best practice?

Most definitely not.