News for hackers. Stuff that matters.
Re:Future JavaScript: what is still missing? by hsavit1 on Sunday January 27, 2019 @10:48AM (#19012102)
If Apple is indeed granted the patent on Swift's optional chaining (as was recently posted https://forums.swift.org/t/apple-is-indeed-patenting-swift-f... ), we wouldn't see this in future Javascript, would we?
Re:Future JavaScript: what is still missing? by realharo on Sunday January 27, 2019 @11:25AM (#19012284)
Groovy had the same feature well over a decade ago[1] (at least in 2005) and other languages possibly even before that. Swift was first announced in 2014.

Swift's is also tied to their `Optional<T>` wrapper type, any potential JS implementation would be more like Groovy's.

[1] https://web.archive.org/web/20050815012153/http://groovy.cod... , bottom of the page

Re:Future JavaScript: what is still missing? by evv on Sunday January 27, 2019 @11:01AM (#19012162)
I'm no lawyer, but I think the Apache2 license on Swift would mean that the JS community has access to the patent.

https://github.com/apple/swift/blob/master/LICENSE.txt

TC39 (who defines Javascript) is a collaboration of several companies, so I'm not sure who Apple could/would even sue if this was proposed and adopted for JS. I doubt we would see legal activity over it.

Re:Future JavaScript: what is still missing? by tirpen on Sunday January 27, 2019 @11:47AM (#19012440)
That sounds like a truly ridiculous patent! Optional chaining is just another syntax for the Maybe-monad, surely?

Which has been around since 1998 at least (When Haskell 1.3 added monads)

Re:Future JavaScript: what is still missing? by mrmr1993 on Sunday January 27, 2019 @11:21AM (#19012269)
I would have thought that Coffeescript's optional chaining, present at least as early as v1.0 in 2010[0], would have counted as prior art.

[0]: https://github.com/jashkenas/coffeescript/blob/1.0.0/lib/par...

Re:Future JavaScript: what is still missing? by k__ on Sunday January 27, 2019 @10:57AM (#19012144)
Is it even a useful feature?

Will it lead to many JS bugs simply disappearing and applications getting more stable or will it just obfuscate bugs in the long run?

Re:Future JavaScript: what is still missing? by realharo on Sunday January 27, 2019 @11:11AM (#19012221)
Presumably people will only use it in situations where null (or undefined, or however it works) is a valid and expected value for a particular property.

In TypeScript, these properties would explicitly have a `MyType|null` or `MyType|undefined` type.

Re:Future JavaScript: what is still missing? by spiritcat on Sunday January 27, 2019 @11:44AM (#19012417)
Roughly speaking, one less place where we need to use lodash.

"or will it just obfuscate bugs in the long run?"

Probably. :shrug emojii:

But more stable in the sense of turning hard crashes into UI quirks.