r/ProgrammerHumor • • Mar 20 '24

Meme areJSDevsActuallySane

Post image
14k Upvotes

554 comments sorted by

View all comments

Show parent comment

-1

u/[deleted] Mar 21 '24

[removed] — view removed comment

3

u/subject_deleted Mar 21 '24

I write JavaScript. Which is why I'm so dumbfounded that people act like these are real problems... In 8 years I have NEVER had an issue like this occur... Nor any of the issues about what NaN matches or doesn't match...

There are myriad ways of doing stupid things in any language. And none of those are a good reason to shit on a language instead of the dumb developer who tried to do something stupid.

4

u/gonzofish Mar 21 '24

But don't you understand?! Because it can happen it's a problem! I've been coding JS for like 20 years in the before times when there wasn't even XMLHttpRequest and I have never run into this.

2

u/subject_deleted Mar 21 '24

I guess long story short... Sanitize your inputs ahead of time instead of relying on error messages to be pre-built-in to the language.

If you have a function that takes a string and passes it to a console log.... A simple if statement to check if it's the correct data type is all you need.

This is how you should handle it even if there was a built in error message.

1

u/[deleted] Mar 21 '24

[removed] — view removed comment

1

u/subject_deleted Mar 21 '24

I could make an equally absurd remark in the opposite direction and it doesn't make you wrong... So why do you think this makes me wrong?

"Why even have programming languages at all? Let's just let coders use ai tools to write perfect bug free code."

It's meaningless to use such absurd examples. We have lots of different programming languages all designed for different things. We need to use those programming languages if we want to write programs. Each language is going to have quirks.

One of JavaScript 's quirks is that it attempts to finish executing no matter what. It prioritizes completion without intrusive errors popping up. That can make for a smoother experience for the user.. but it also means the developer has to be careful.

There are obviously other languages designed for other purposes where the priority was skewed heavily towards calling out every error.

1

u/[deleted] Mar 21 '24 edited Mar 21 '24

[removed] — view removed comment

1

u/subject_deleted Mar 21 '24

I just have a deep aversion to fanboyism on anything which a lot of the comments here piqued.

I'm not fanboying at all.... I'm pushing back on the absurdly intense criticism that JavaScript gets for the sole reason that it doesn't explicitly tell you when you fucked up... I'm trying to get people to understand that if they're writing code like that.... It's not the language's fault that their debugging sessions are harder than they should be.

If anything you're acting as a fanboy of the "anti-js crowd".

but to pretend that doesn't come with a host of unsavory qualities,

At no point did I pretend js has no unsavory qualities.... I'm just not putting the blame on the language when developers do stupid shit the language wasn't meant to do.

If a car breaks down because the owner never changed the oil.... It's not a problem of the car. If a 747 crashes because the pilot went rogue and decided to try a barrel roll... That's not a fault of the 747.

Anything can break if you use it in a way that wasnt intended.

Even if I wanted everything to execute no matter what -- Why would I not want to warn the user at the very least when I coerce an object to the string 'Object object' ?

Because 99.9% of users would have absolutely no idea what that means. It's not a helpful error message for them. And the problem should reveal itself in testing, not in production.

It's not that JS throws no warnings or errors, so how can we really defend this without some hero worship of the language because it is known to us?

It throws errors when something is bad enough that it literally can't proceed...

Who's hero worshiping? All I've said is that the fault lies with the people doing stupid shit, not the language they're writing it in. I'm not claiming JavaScript is perfect or divine or free of flaws... I'm saying that it has flaws just like all other languages.

I could sit down and come up with quirky things about every major language... And that task wouldn't do anything to actually make those languages bad. It would just prove that I thought of a lot of ways to break them.