Hacker News new | past | comments | ask | show | jobs | submit login

I like most of what I see in the sane mode. I would even go further and make "" and 0 truthy in that mode.

I don't think I would use the type system. Maybe it should have its own proposal instead of being "bundled up" with sane mode. At least it is optional.




Making 0 and "" truthy is just asking for trouble, whatever your opinion of current JS semantics. The hope with sane mode (or whatever less able-ist name it should have) is to have no runtime semantic change if the mode directive is not recognized (as it won't be, if a quoted prologue directive aka useless string-literal expression-statement, in any downrev browser).

Doubling the testing load, making hidden time bombs for older browsers to find blowing up in their faces at later dates: Not Good.

Elsewhere here, both Alon Zakai I question the wisdom of using an erased "use sanity"; mode directive, given that runtime semantics will diverge for any code not in the new subset. The hope is that people will test fully with checks on, and find all code that doesn't follow the rules. I think TC39 will balk at this hope. Murphy was an optimist.

/be


Hi there, thanks for taking the time to comment.

> The hope with sane mode (or whatever less able-ist name it should have) is to have no runtime semantic change if the mode directive is not recognized

From my limited understanding, old browsers can't handle 'let' anyway, which is supposed to be used exclusively on this mode (as there will be no 'var'). But you probably know more about this than me.

> making hidden time bombs for older browsers to find blowing up in their faces at later dates: Not Good.

Doesn't that happen all the time? What I mean is: If ES6 becomes widely supported in browsers, pages written on it will make old browsers "blow up", too. Unless the people who program those make two versions, which defeats the point of using ES6 in the first place. The same when a new version of CSS comes out - use that, and the old browsers "blow up", too.

It seems to me it is the nature of the beast - new features make old browsers blow up.


It turns out `let` is usable in most browsers today, and in some older ones. The point is there's no extra opt in and no forked runtime semantics.

> Doesn't that happen all the time?

You're talking about new syntax bombing old browsers. That's not the issue. The issue is same syntax in old and new, works (for whatever value of "works") in old and new, but differs in meaning due to a "use sanity"; directive.


Fair enough. You have probably heard arguments similar to mine hundreds of times, thanks again for answering.

For what is worth, I never depend on the truthyness of falsyness of 0 and "", and always test for them explicitly, so it will not affect my code if in a distant future javascript starts treating them as truthy. Just, you know, in case you change your mind in the future.

Good night!


I, for one, sincerely hope the semantics of truthy/falsy operations of which I've grown accustomed to these past 19 years don't change. I tend to appreciate these expressions in JS moreso on actual user input operations.


The likely TC39 debate is between Dart-like Puritanism: no implicit conversion from primitive values or object references to Boolean values; vs. implicit conversion of primitives but not of object refs. I'm in the latter camp.

Update: this does not say 0 == "" of course, separate issue.

/be




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: