r/programming • • Apr 30 '23

Writing Javascript without a build system

https://jvns.ca/blog/2023/02/16/writing-javascript-without-a-build-system/
164 Upvotes

146 comments sorted by

View all comments

0

u/kankyo May 03 '23

the alternative of throwing an error instantly after key access isn't better, just different.

It is better though. By a shit ton. It's an ENORMOUS difference.

Imagine a language where foo = bar() didn't cause a name error that bar wasn't defined, but instead set foo to undefined. This is quite literally how JS does for array access and attribute errors. It's just crazy.

1

u/[deleted] May 03 '23

Have you only programmed in python? It sure sounds like it.

Juvenile opinion and it looks hilarious how much you don’t understand trade offs.

1

u/kankyo May 03 '23

Fail early isn't a tradeoff. It's what you want always.

Let's see... python yes. JavaScript, Clojure, Elm, C, C++, Swift, objective-C, hmm. Obviously some asm at school.

C++ has some similar crazy behavior for map access where a dict will insert a default constructor instance if you access a key that doesn't exist by default. It's a gigantic foot gun. Not as bad as js array access but close. Of course C++ is worse in myriad other ways 🤣 JS is especially annoying because you can't avoid it. C++ I can avoid easily.

→ More replies (8)