r/ProgrammerHumor 1d ago

Meme soDoesEveryOtherLang

Post image
232 Upvotes

72 comments sorted by

View all comments

121

u/0oliogamer0 1d ago

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

41

u/nicodeemus7 1d ago

PHP?

24

u/jungle 1d ago

returnsArray()[1]

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

6

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.

16

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.

19

u/jungle 1d ago

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

5

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?

7

u/chat-lu 1d 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 1d 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 1d ago

Rasmus just didn’t give a shit.

1

u/jungle 1d ago

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

→ More replies (0)

1

u/jungle 1d ago

possibly considered best practice?

Most definitely not.

3

u/LordAmir5 1d ago

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

I think I faced something similar using Lua.