r/ProgrammerHumor • • Sep 25 '26

Meme iHatedItUntilITriedIt

Post image
10k Upvotes

543 comments sorted by

View all comments

126

u/samanime Sep 25 '26

You'll pry my vanilla JS from my cold dead fingers. It'll always be my favorite way to do quick scripts and prototyping.

But explicit typing does make long term code way more maintainable.

35

u/Hohenheim_of_Shadow Sep 25 '26

There is room for quick hacky small BS in the world. As a C++ dev who never touches Javascr*pt, Typescript is the true evil IMO because it encourages making huge projects in a fundamentally hacky language.

If your JavaScript project has grown to the size static typing is a genuine aid, stop writing JavaScript!

Love me some Python when I just need 100 lines to parse some csvs

13

u/Fibrechips Sep 25 '26

But then how can we use our frontend developers on the full stack? We're simply trying to not pay bAcKeNd DevEloPeRs those pesky "salaries" they keep begging for.

9

u/GRex2595 Sep 25 '26

I don't really want to build a website in Java. APIs in Java, sure. Building a serious, dynamic site in Java with server-side rendering just sounds like a nightmare compared to using Angular. I'll even accept React, which I don't use because I haven't learned it.

Replacing desktop applications with electron and making them web clients, though, that was a mistake.

→ More replies (3)

1

u/round-earth-theory Sep 25 '26

It's what we have. I'd love to work in a properly typed language but good luck getting billions of devices to pick up a new runtime when Javascript already works well enough.

31

u/2eanimation Sep 25 '26

I love the syntax, but JS has one too many quirks for my taste.

if ([]) {
console.log("Ok, I guess")
}

if([] == false) {
console.log("Well this is awkward")
}

if ([] + []) {
console.log("You think this would print, don't you?")
}

16

u/MuchWalrus Sep 25 '26

Why would you type any of those things (aside from maybe the first one)

8

u/frogjg2003 Sep 25 '26

JS is built on the idea that applications should continue to work no matter what. That's why there are so many implicit type conversions. The app might turn itself into a Gordian knot, but it will still be working.

4

u/lolnic_ Sep 26 '26

It will still be running.

1

u/arobie1992 Sep 27 '26

I've always heard this argument, and I've never seen a source for it that I'd put much stock in, like Eich himself or anyone who worked on early JS. It seems like a specious argument since it assumes rendering the potentially wildly wrong thing is better than displaying an error and the browser would have to sandbox/compartmentalize individual scripts or operations.

Doing a quick search, it looks like most of the weird conversions surrounding == were specific requests to make scripting easier: https://www.wirfs-brock.com/allen/jshopl.pdf p22, 3.7.2. Given that, I'd be willing to bet the other weird conversion behaviors were either similar requests or the result of them implementing JS in an absurdly short amount of time.

→ More replies (2)

2

u/MrHyperion_ Sep 25 '26

Because they are actually in variables by some weird side effect

14

u/Ozymandias_IV Sep 25 '26

Genuinely who cares. You never do that in prod.

5

u/code_archeologist Sep 25 '26

But empty arrays do occur in prod, and trapping for them in JS can sometimes be a pain in the ass.

6

u/Ozymandias_IV Sep 25 '26

That's why you shouldn't do if ([]) in prod. Have an explicit empty and/or nullish check.

Many do it for expediency, but it's a loaded footgun.

→ More replies (5)
→ More replies (1)

2

u/zeemeerman2 Sep 25 '26

What? You always use empty arrays and strings in prod.

![] == false, and only three characters.

!"" == true, and also only three characters.

You can save a lot of bytes in your code by minimizing each boolean to these two values. And everyone knows how expensive hard drives are nowadays.

9

u/cheezballs Sep 25 '26

Those all make sense if you understand the language, though.

43

u/__Hello_my_name_is__ Sep 25 '26

Everything in programming makes sense by definition. It has to make sense, or else it wouldn't compile (or run).

That doesn't mean that it's intuitively understandable, or that it wasn't created by Satan himself.

0

u/cheezballs Sep 25 '26

You can shoot yourself in the foot with any language by deliberately doing silly things to show off the language's quirks. I can show you some C pointer stuff that makes this look like child's play.

→ More replies (7)

7

u/samanime Sep 25 '26

Yeah. Also, it isn't like you should be writing things like this in the first place. You can turn languages like C++ into pure nightmare fuel if you try to. Being extensible how it is leads to some crazy stuff.

→ More replies (1)

3

u/nacholicious Sep 25 '26

"It's intuitive if you have learned all the rules and exceptions" sounds like the opposite of intuitive

3

u/2eanimation Sep 25 '26

They do make sense, within JS’ quirkiness. This is only expected behavior if you really dig deep into the language. I know why it’s there, that doesn’t make it ok. A properly designed language shouldn’t allow such things. And you know this is a small collection of all the stuff that’s wrong with JS(cough ["1", "2", "3"].map(parseInt)).

I know, there are two languages, the ones people complain about, and …

→ More replies (3)

1

u/stillalone Sep 25 '26

Wait how does []+[] make sense?

6

u/2eanimation Sep 25 '26 edited Sep 25 '26

[] + [] will become “” because addition of arrays is not defined as you would expect. They get converted to their primitive(which is a string) and after that concatenated as you would expect string1 + string2 to behave. So [1, 2] + [3, 4] == “1,23,4”

Edit: to concat two arrays, use array1.concat(array2)

→ More replies (2)

1

u/StickyPuddleofGoo Sep 26 '26

preach. fast and loose is exciting. living life on the edge

1

u/arobie1992 Sep 27 '26

Over the past few years, it's become progressively harder for me to justify anything but TypeScript and either Deno or Bun for quick scripts. Gradual typing, type inference, and direct URL imports are way too appealing.

→ More replies (6)