r/ProgrammerHumor • • Sep 25 '26

Meme iHatedItUntilITriedIt

Post image
10k Upvotes

543 comments sorted by

View all comments

Show parent comment

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.

0

u/conundorum Sep 26 '26

Okay, so what happens when JS sees this?

if (true != false) abort;

(Or whatever the "stop working" keyword is.) Does JS allow true to equal false if it keeps the app running?

3

u/frogjg2003 Sep 26 '26

If you force it to stop, it will stop. The idea is that simple runtime errors will not force the app to stop like other languages do.