3 ms·
I want to see something like Flow integrated into the js specs. Types can help optimization just as they can help correctness!
by rptv 8y ago
I want to see something like Flow integrated into the js specs. Types can help optimization just as they can help correctness!
- rictic 8y agoPossibly! But trickier than it seems at first. For types to help with optimization, those types have to be correct and reliable (i.e. sound). If every line of your app and all of its dependencies are sound, then you should expect a speedup. If there is any unsound code, then you'll have to generate runtime checks to preserve the soundness properties that your optimizer assumes, and those can actually result in _slower_ code. Even Flow has made compromises that are good for a type checker, but likely unacceptable if an optimizer is relying on them. Quoting https://flow.org/en/docs/lang/types-and-expressions/ https://flow.org/en/docs/lang/types-and-expressions/ > Soundness is fine as long as Flow isn’t being too noisy and preventing you from being productive. Sometimes when soundness would get in your way too much, Flow will favor completeness instead. There’s only a handful of cases where Flow does this.
- esturk 8y agoThere are stuff that flow doesn't even handle such as inline destructure with types. Imagine how complicated it gets at the engine level of parsing the syntax.