Live data from Hacker News

The void of undefined in JavaScript

shapeshed.com

31–34 of 34 posts

Re: The void of undefined in JavaScript

#31
post #29

Earlier quoted context omitted.

This is one among many serious, and unjustifiable, flaws with JavaScript. It's the kind of issue that should never even arise with anyone's code in the first place, regardless of who wrote the code, because the language and its implementations should not allow it to happen. And, yes, we know that other languages have flaws, too. But aside from perhaps PHP, the flaws in other languages are almost never as outright stu…

> And, yes, we know that other languages have flaws, too. But aside from perhaps PHP, the flaws in other languages are almost never as outright stupid as they are with JavaScript. Citation needed. There are tons of languages with huge fucking flaws to blow your code and kick your dog. PHP and Javascript are relatively harmless (if a little brain damaged). At least you don't get buffer overflows using them. You think…

No, the OP was correct - other languages have flaws but nowhere near the level of Javascript. You pick on C++ which is a design by committee monstrosity but it is nowhere near as braindead as Javascript. I mean, C++ allows you to include other code! C++ doesn't allow you to redefine the constants of the language. Actually, C++ has constants!

Nope, as much as I like to rail against the sins of C++, it is a paragon of design virtue next to JS. I've been programming for three decades now and JS is the worst language I have ever seen. I use JS a lot in my day job and it has parts I really like (object constants, for example) but really, as a piece of language design it is really the pits.

Re: The void of undefined in JavaScript

#32
post #6

Earlier quoted context omitted.

A quick search of github gave this line: var undefined= undefined; Which has a comment explaining that it is an optimisation based on the idea that "defined variables are faster than not-defined ones" - I have no idea if that is true or not. https://github.com/Searle/mothello/blob/c31fc57bedd666e9da34... I wonder if this counts as redefining undefined though! The comment also suggests that jQuery does this, which see…

If you have to guard against someone doing something silly, then you are never safe. The problem is not the language at that point, it's the environment.

To err is human -- you're never safe. Even if we say people are the root of the problem, fixing their fundamentally imperfect nature is currently beyond the capabilities of science, whereas doing something like enforcing constants at a language level is not. Education will reduce, but not eliminate, the chance of making such a mistake.

Re: The void of undefined in JavaScript

#33
post #31
post #29

Earlier quoted context omitted.

> And, yes, we know that other languages have flaws, too. But aside from perhaps PHP, the flaws in other languages are almost never as outright stupid as they are with JavaScript. Citation needed. There are tons of languages with huge fucking flaws to blow your code and kick your dog. PHP and Javascript are relatively harmless (if a little brain damaged). At least you don't get buffer overflows using them. You think…

No, the OP was correct - other languages have flaws but nowhere near the level of Javascript. You pick on C++ which is a design by committee monstrosity but it is nowhere near as braindead as Javascript. I mean, C++ allows you to include other code! C++ doesn't allow you to redefine the constants of the language. Actually, C++ has constants! Nope, as much as I like to rail against the sins of C++, it is a paragon of…

#define ?

Re: The void of undefined in JavaScript

#34
post #31

Earlier quoted context omitted.

No, the OP was correct - other languages have flaws but nowhere near the level of Javascript. You pick on C++ which is a design by committee monstrosity but it is nowhere near as braindead as Javascript. I mean, C++ allows you to include other code! C++ doesn't allow you to redefine the constants of the language. Actually, C++ has constants! Nope, as much as I like to rail against the sins of C++, it is a paragon of…

#define ?

That's not really a C++ construct, as much as it is a hold-over from C, kept around to retain compatibility with existing code.

If you're writing new C++ code, you're in no way forced to use it. You can use constants or inline functions to achieve the same result in almost all cases.

Post reply on HN