-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No need for 2 "absence representations" #26
Comments
Words from the language creator:
This makes sense to me. Keeping the issue open nonetheless and I'll write something about it one day. It seems like an interesting piece of information to be aware of if designing a compile-to-JS language. |
I disagree with that. |
Ah, so JavaScript values are |
@michaelficarra |
This shouldn't be a regret, but a win for the language. Having both |
Some how all other languages do just fine without distinction not existing values and intentionally emptied values. If one for some reason wants to empty a value but signify the fact that it exists never the less usually new special Type / Constants are used in other languages that do job well, also discouraging that pattern. So sure there is a difference between |
The same argument can be used on the reverse: JavaScript has both Now,
special type like... lets see.... I'd argue that even those languages with only
|
My point is Null objects are quite exotic, JS makes them mainstream and more things to comprehend is rarely makes things simpler. |
Simple languages produce complex frameworks, complex languages produce simple frameworks. It is only a matter of subjective preference where you want the complexity in. And why are Null objects exotic, but CONSTANTS not? Simply because they don't teach you that pattern at school. So, exotic is only what you don't quite understand. And not understanding |
Take a look at lua very similar to JS with much less misfeature than in JS (including this one). Does great without Null objects or special Constants etc.. Very simple designed such that you don't need to have that distinction. It's just a good language design! For example clojure data structures are immutable (like strings in JS) but language designed such that it's just feels great, in contrast try writing JS without mutations and it will be a pain. My point is sure every feature can be justified, although some can be just simplified. Either way I don't feel like continuing this discussion as it clearly isn't taking us anywhere. Claiming that only JS got it right is just ridiculous, all good ideas are usually adopted by new languages that come after, I'm afraid this one does not seems to pick up. |
@Gozala Looking from right angle we can say that concept of
While I find 1 as expected behavior, which I like in JavaScript and definitely wouldn't change, 2 is indeed controversial thing, we're probably questioning. I think it would be more logical if assignment of var x; // x === undefined
x = 3;
x = undefined; // No effect, throw in strict mode
delete x; // Brings back x === undefined Currently it's exactly opposite, delete on local variable has no effect and throws in strict mode, and assignment of Same way with properties, but here delete works as intended, it clears property which then fallbacks to value of same property of its object's prototype. So reassuming both are needed, what's controversial is that |
There are languages where Also please do not explain me difference between That being said, I'm happy(more honestly sad) to see so many people be so passionate about this (miss)feature. |
@Gozala in data related logic it's sometimes important to know, whether value is intentionally |
Forked out of #25.
JavaScript has both
undefined
andnull
while only one could be enough.The text was updated successfully, but these errors were encountered: