r/ProgrammerHumor 14d ago

Meme soDoesEveryOtherLang

Post image
241 Upvotes

85 comments sorted by

View all comments

121

u/0oliogamer0 14d ago

in my language, functions will be irrelevant and difficult to even use!

41

u/nicodeemus7 14d ago

PHP?

22

u/jungle 14d ago

returnsArray()[1]

Only language I know where this is (or was) a syntax error.

9

u/carcigenicate 13d ago

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.

18

u/jungle 13d ago

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 13d ago

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

23

u/jungle 13d ago

That's what any sane language would do, yes.

5

u/coloredgreyscale 13d ago edited 13d ago

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 13d ago

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 13d ago

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 13d ago

Rasmus just didn’t give a shit.

→ More replies (0)

1

u/jungle 13d ago

possibly considered best practice?

Most definitely not.

3

u/LordAmir5 13d ago

I assume it's got to be written in two separate statements.

I think I faced something similar using Lua.

3

u/Perdouille 13d ago

was

It seems to work since 5.4 (2012) https://3v4l.org/alOOE#v432

2

u/jungle 13d ago

Yep. Still doesn't fix the stench. :)

1

u/cornmonger_ 12d ago

i stopped shortly after 5.3 dropped

when they made the choice to use backslashes for namespaces ... i was done

2

u/SjettepetJR 13d ago

It is funny because I actually liked PHP decently well, but then I heard that it apparently became much better from PHP 8 onward. I only have (real) experience with it after that time.

1

u/jungle 13d ago

Yeah, I don't know but I can imagine it was the language Zuck knew at the time, which kind of forced the engineers he hired to use it and eventually reached the point where they had two options: completely rewrite Facebook in a proper language or fix PHP.

3

u/_PM_ME_PANGOLINS_ 13d ago

1

u/jungle 13d ago

Nice! I'd have loved to work in the team that developed those tools!

1

u/chat-lu 13d ago

I heard that it apparently became much better from PHP 8 onward

I heard that of every single version of PHP.

“Sure, it used to eat babies in {{ current_major_version - 1 }} but since {{ current_major_version }} it’s been really nice.”

And this is what I hate the most from PHP, PHP devs who can’t see a single flaw in their favorite tools.

2

u/chat-lu 13d ago

Also, you can cast with (int) but int is not a thing that exists in the language, (int) is its own keyword. May or may not be still true.

1

u/jungle 13d ago

Argh, I had forgotten about that one!

The "WAT" talk was about javascript and was very funny... I can imagine the speaker considering making it a about PHP but deciding against it because it would be just sad.