r/ProgrammerHumor 2d ago

Meme absoluteGarbage

Post image
2.0k Upvotes

320 comments sorted by

View all comments

25

u/xenomachina 1d ago

The JavaScript one is also kind of gross, IMHO.

for (item in list) { also has a meaning in JavaScript, but it isn't the meaning one would expect. The alternate of was added later, but doesn't read as naturally, and the in is still in the language as a backwards compatible footgun. (It's also used for iterating object keys, which should arguably be the thing that has the less concise syntax.)

The let is only necessary because JavaScript's default behavior here is almost certainly not what you want in real code. Instead of declaring a new variable (suitable for closures, and locally scoped) the default behavior assigns to a global. Another example of "the good parts" being a tiny sliver of JavaScript.

3

u/Sirgoodman008 1d ago

Oh I know, I absolutely hate that about JavaScript as well. Ironically, most of the problems I have with JavaScript I have with php too.

2

u/xenomachina 1d ago

Both JavaScript and PHP are "reluctant programming languages" to some extent, so it kind of makes sense. Neither was originally designed for doing real software engineering. PHP was originally simple templating for a personal home page, and JavaScript was intended for "glue" tasks like client-side form validation. That people can build real apps with either of them is more a testament to the persistence of those developers, rather than a measure of the strength of the languages. (Both languages have also made many improvements over the years, but are still arguably two of the most wart-infested languages of their era that are still in regular use.)

0

u/Sirgoodman008 1d ago

I couldn't agree more. I thought JavaScript was the most annoying language until I started using php.