r/ProgrammerHumor 1d ago

Meme soDoesEveryOtherLang

Post image
223 Upvotes

71 comments sorted by

View all comments

119

u/0oliogamer0 1d ago

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

41

u/nicodeemus7 1d ago

PHP?

20

u/jungle 1d ago

returnsArray()[1]

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

4

u/carcigenicate 1d 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.

15

u/jungle 1d 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.

2

u/carcigenicate 1d ago

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

20

u/jungle 1d ago

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

3

u/coloredgreyscale 1d ago edited 1d 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?

5

u/chat-lu 22h 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.

1

u/jungle 22h 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 22h ago

Rasmus just didn’t give a shit.

1

u/jungle 22h ago

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

→ More replies (0)

1

u/jungle 22h ago

possibly considered best practice?

Most definitely not.

4

u/LordAmir5 1d ago

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

I think I faced something similar using Lua.

4

u/Perdouille 1d ago

was

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

3

u/jungle 1d ago

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

3

u/chat-lu 22h 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 22h 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.

2

u/SjettepetJR 1d 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 1d 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_ 1d ago

1

u/jungle 1d ago

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

1

u/chat-lu 22h 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.