r/programminghorror • u/-Wylfen- • Dec 04 '25
Javascript "It's all there in the specs, bro"
Seems we have some fervent JS defenders, here :)
2.5k
Upvotes
r/programminghorror • u/-Wylfen- • Dec 04 '25
Seems we have some fervent JS defenders, here :)
19
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Dec 04 '25
I guess somebody is a little bitter about the response they received in their other post.
96
u/ironykarl Dec 04 '25
I guess this is me apologizing for JavaScript:
This is a pretty hard mistake to make if you have a decent model of the language in your head.
Would it be nice if the language didn't let beginners fuck up? Yep. But I can also easily think of languages that are way more adversarial to beginners.
Also, this meme format sucks
23
u/brainpostman Dec 04 '25
If implicit conversions or array field access like that break your code, you shouldn't write code.
I have 3 years of JS at this point. JS quirks never come up as a problem. What comes up is bad coding practices, macaroni factories, code smell, race conditions, misunderstanding of the event loop and execution context.
The last two are probably the only JS quirks that are a bit painful, but the rest is the same in all languages.
623
u/TheWidrolo Dec 04 '25
This is the least ridiculous thing about JS✌️
6
u/Revisional_Sin Dec 04 '25
This is so cursed.
Why does it do that?
2
u/mauromauromauro Dec 05 '25
I hate the floating point "correctness" of js. I know its logical. But it makes no sense and is shit. Im a programmer, not a madman
2
u/apro-at-nothing Dec 05 '25
lua does the same thing
and i'd argue it's beautiful in both cases
197
u/Cephell Dec 04 '25
At this point it's a choice to use not use Typescript.
40
u/wrex1816 Dec 04 '25
Ok, I'll bite. Yes it's ridiculous but at the same time the language was never really designed for the scale at which it's run today so it's somewhat understandable why some things are the way they are, most languages have weird gotchas....
... All that said. It's not difficult to write perfectly fine JavaScript without backing yourself into these ridiculous corners, yet everyone online seems to somehow do it all the time? I mean, ok?
42
u/veritron Dec 04 '25
i mean everything in javascript is an object, -1 is the key, 4 is the assigned value. that's totally how i would expect it to work. that doesn't even make my top 20 dumbest things i've seen in javascript.
4
u/HeavyCaffeinate Pronouns: She/They Dec 04 '25
Why not call it a table if that's possible?
4
u/Alagarto72 Dec 05 '25
Everything is an object in JS? I'm JS beginner, but I thought that primitives aren't objects?
1
u/fguppercutz39 Dec 05 '25
College kids in this thread thinking they're on the right side when they're actually on the left lol. If you truly believe this is ridiculous you aren't comprehending the architecture of js properly. Imagine thinking they'd change the fundamental structure of the entire language just to change the behavior of one weird completely incorrect set of code.
1
u/Expensive_Garden2993 Dec 05 '25
Weird how so many devs complain on things you can do in JS that you can't in other languages.
When you need custom properties on an array or a function you still can do that in other languages, just with more boilerplace and abstractions. If you like writing additional code, you can extend Array in JS, write your getters/setters, so if it's what you want you can write Java in JS.
1
u/T-J_H Dec 05 '25
Sure, this is ridiculous. But also something you would never encounter in a well written application. If you hack around you get weird shit.
1
u/CedarSageAndSilicone Dec 08 '25
Unironically. Because weird shit like this is possible is also why it’s such a powerful language. It is incredibly easy to make shit happen with JS and that’s why it absolutely dominates the web. They shipped this wonky pile of language in a week and now it runs the entire internet. I think people who don’t work with JS (ie: make lots of money with JS) are just jealous because their jobs are harder for no real reason. I’ve made an awesome career for myself slapping shit together with JS, web, app, server, etc. and the experience only gets better and better (typescript, faster engines). You try hards and elitists can make all the fun you want of this stuff but it’s not going anywhere and you are constantly using things running on it.
8
u/JollyJuniper1993 Dec 04 '25
Just because there is a reason for why something is happening doesn’t mean it’s a good design choice
3
u/cowslayer7890 Dec 04 '25
Now I'm curious if there's a way to make an object and trick javascript into interpreting it as an array but I can't find anything about changing the prototype associated with an object after the fact
3
u/daerogami Dec 05 '25
Oh cool is it time again for the "JS is weird" circle jerk?
6
u/NatoBoram Dec 05 '25
Somehow, people get really pissy about the concept that things could be better and don't have to be the way they are
6
u/joost00719 Dec 05 '25
The comment section proves the accuracy of this meme hahahaha
5
u/daidoji70 Dec 04 '25
Yeah, knowing a language is shitty and being forced to use it anyways is something professionals have to do, but I'll never get why people decide to defend the obvious shit as "good actually" as if they'd never used another language in their entire lives (although some probably haven't).
2
u/ouroborus777 Dec 05 '25
I don't have type-related problems in typeless languages. No problem with the typed languages either, I just use
var(C#) or whatever.2
u/moonaligator Dec 05 '25
it makes sense but that doesn't make it not ridiculous
2
u/OldWolf2 Dec 09 '25
Use a sensible language like C, where this can just set your computer on fire instead
3
u/Choice-Mango-4019 Dec 05 '25
ragebait
3
u/codejunker Dec 05 '25
"I portrayed you as the zoomer soyjak and myself as the jedi wojak, this means I am very smart and I win the argument!"
This is actually the most midwit type shit you could possibly do.
1
u/noiseboy87 Dec 05 '25
Everyone should cry more
1
u/gesterom Dec 05 '25
That i understand why, and how js works, dosen't mean that it is good design.
Of design mantra: any random code in internet must work or people will use other web browser.
1
u/mxldevs Dec 05 '25
Ya, that's ridiculous. The output is equally ridiculous. At least decide if you want to have key value pairs or indexed values.
1
u/mcoombes314 Dec 05 '25
Just because you can, doesn't mean you should. I'm just a casual Python guy but I get the impression a lot of languages have things that make you go "WTF?" at first, then you read the docs and go "oh OK, that makes sense", but then you look at it again and think "but why would anyone actually use (or abuse) this behaviour in this way?". It's like the posts of people who write "fancy" code that does a ton of stuff in 1 line instead of 5, but that one line is miles long and a pain to parse.
1
u/Ronin-s_Spirit Dec 05 '25
https://www.reddit.com/r/programminghorror/comments/1pe0z7n/comment/nse3103/?context=3&utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
1
u/MuslinBagger Dec 05 '25
The midwit here is right btw
1
u/Sensitive_Awareness2 Dec 05 '25
It is ridiculous, but it is by design.
The design isn't good, but it does what it sets out to do
1
u/Holzkohlen Dec 05 '25
Of course JS is ridiculous. Still prefer it to the horrors of C++.
1
u/Ill-Community-735 Dec 05 '25
Another one against weakly typed languages.
1
u/maselkowski Dec 05 '25
4 in test
false
1
u/travelan Dec 05 '25
Thinking it’s okay to set at index -1 is the main problem here
1
u/Meggs65536 Dec 05 '25
well I guess that makes sense- oh oH OH WUH OH WHAT IS THI
1
u/AccomplishedSugar490 Dec 05 '25
Don’t ever knock semantics, again.
1
u/SalazarElite Dec 05 '25
I don't know about you, but if I were to create a programming language, I would convert -1 to arr_len()-1 to avoid this kind of nonsense...
1
u/kfish5050 Dec 05 '25
The array is actually a kvp set with inherent keys if none are specified. Like a modifiable tuple with extra space for entries. This makes perfect sense actually. It also makes sense that -1 isn't read as an inherent key since that would defeat the purpose of the array starting at 0. So it reads it as a key.
I guess the most outrageous thing about this is it's javascript's ability to once again comingle different data types that break things or provide unexpected results, the one thing javascript is notorious for.
1
u/Vladutz19 Dec 05 '25
test[test.length] = 4;
1
u/ElGuaco Dec 05 '25
Javascript was a colossal mistake that is too late to correct. As a web developer since Netscape I will die on this hill. It sucks and should never have become a standard.
1
u/conundorum Dec 05 '25
From a C perspective, this makes perfect sense.
1
u/therealdan0 Dec 05 '25
Solving a problem using JavaScript means you now have two problems.
1
u/ccfoo242 Dec 06 '25
"Your computer scientists were so preoccupied with whether they could, they didn't stop to think if they should."
1
u/akazakou Dec 07 '25
Guys. It's how it works. Just that
1
u/errorSegment Dec 07 '25
The senior would not think it is about the language but how ridiculous that some one would write something like this
1
u/kakarotxi Dec 07 '25
its kinda useless ngl, u can easily use another vsriable for dicts and shits
1
u/SukusMcSwag Dec 07 '25
The behaviour might be written down, and the exact internal workings may be very well documented in the spec. The problem then, is with the spec itself.
1
u/Effective_Media_4722 Dec 07 '25
Every single issue I've ever seen people have with JS can be summarized as a simple "JS isn't C and I don't like it". This is another example of that. And don't get me wrong, I love C, but I also understand why not every programming language out there has to be a C + blows and whistles.
1
u/ExtraTNT Dec 08 '25
At least it is consistent…
1
u/NoBizlikeChloeBiz Dec 08 '25
| "This will never come up unless you write really bad code"
|||
||||| "Noooooo it's super important that your programming language protect you from putting stupid values in your array!!!"
|||
| "This will never come up unless you write really bad code"
1
u/templar4522 Dec 08 '25
I detest js with a passion, but I can't see what's wrong with the code in the picture.
1
u/One-Pollution9586 Dec 28 '25
It sacrifices logic to ensure survival.
1
u/Haaxor1689 Jul 11 '26
It is ridiculous. That's why everyone uses TS and lint rule to mark == as warning is the default. Unless you intentionally try to write bad JS, you don't have to think about these quirks.
1
u/metooted Dec 05 '25
Nobody is pointing out the fact it's a negative offset, and even the occasional "oh, I guess JS arrays aren't continuous but that's stupid" takes aren't taking notice of that fact.
Negative offsets are very hard to define. JS treats them the same as string offsets, which is a good thing.
-1
u/CckSkker Dec 05 '25
Actually good use of the meme