4 ms·
Another Facebook project Flow gives similar if not as comprehensive benefits whilst staying in JavaScript.
by hazza1 9y ago
Another Facebook project Flow gives similar if not as comprehensive benefits whilst staying in JavaScript.
- yebyen 9y agoDoes it really stay in JavaScript though? I'm not familiar with the latest ECMA and standards updates and I suppose I don't really know what modern JS actually looks like, but the example on this page[1] doesn't look like syntactically valid JavaScript to me. If you write code that has to be compiled before it turns into JavaScript, there's another benefit though... it's that you can never accidentally promote code to a server that hasn't already been vetted by the type-checker! Or, even run it locally! You are guaranteed that the type checker has been run before the code hits a runtime environment. Looking at Flow, I'm seeing there's a tool `flow` that you run any time you want to check the types. I think there's a background process way to run flow, that mitigates this issue somewhat... but if Flow is in fact implemented to always be syntactically valid JavaScript, that could be a bad thing. [1]: https://flow.org/en/docs/usage/ https://flow.org/en/docs/usage/
- hazza1 9y agoRealtime checking is trivial with the appropriate IDE extension and you can always put the type annotations inside comments - https://flow.org/en/docs/types/comments/ https://flow.org/en/docs/types/comments/
- Touche 9y agoNo, Flow is not JavaScript, it's a superset.
- Raphael 9y agoBabel has a bunch of extensions to JavaScript that are widely used. Sounds like it just finds and strips out type annotations. https://babeljs.io/docs/plugins/syntax-flow/ https://babeljs.io/docs/plugins/syntax-flow/ https://babeljs.io/docs/plugins/transform-flow-strip-types/ https://babeljs.io/docs/plugins/transform-flow-strip-types/