Similar to the Google Closure Compiler ( https://developers.google.com/closure/compiler/ ), which has been around for years, just with fewer features. It has static type checking with optional type annotations and type inference. It doesn't have compiler-time constants, dead code removal, inlining, or other optimizations. But....still really cool.
Facebook Launches Flow, Static Type Checker for JavaScript
271–280 of 282 posts
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#272Another comment that just occurred to me: JavaScript becoming gradually typed is an interesting reflection of the recent history of the optimization of JavaScript interpreters, which consist of deducing where semantically dynamic objects behave like static class instances, then inlining the accessors and where beneficial, the "class methods", and specializing && JITing the semantically dynamic functions that almost a…
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#273Static types without performance benefits. So far, all popular static type systems have had the performance benefits, so it's unclear how much people value the other benefits (quality and documentation). I wonder which will have the most impact: code quality or types as documentation (esp for tooling)? They are adapting to common idioms, rather than designing it from the ground up. This ad hoc approach is a great way…
Also, if you're code is implicitly statically typed (as checked by Flow) you will likely hit all the right optimizations in the underlying JavaScript VM.
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#274One of the authors of Flow offered to answer questions, but their comment is greyed out as a dupe (and it isn't a dupe - something went wrong): https://news.ycombinator.com/item?id=8625406
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#275How does static checking work with dynamic types? Can the type checker figure out if a field/method exists on a type given that it can be added dynamically? Edit: I assume it just checks bool/number/string and doesn't care about prototypes?
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#276That is quite impressive. No type annotations needed, and control flow is taken intro consideration (hence the name I guess). If I am not mistaken, this tech could be used to build IDEs roughly similar to whats available for Java, couldn't it?
It looks like it's designed for the IDE use case - on cursory inspection of the code, it contains an autocomplete database and a client-server architecture designed for editor plugins (with useful interfaces like "type at character index"). I'm surprised that they don't seem to have launched with a public editor plugin and that the documentation doesn't seem to mention it.
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#277One of the authors of Flow offered to answer questions, but their comment is greyed out as a dupe (and it isn't a dupe - something went wrong): https://news.ycombinator.com/item?id=8625406
The problem was that there were two identical comments, the software killed one as a dupe, and avik deleted the other one. The software tries to fix this very scenario—it normally would have automatically unkilled the remaining member of the pair. But there are some corner cases where that doesn't work, and avik seems to have outsmarted it.
We'll take a look and try to fix the fix.
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#278Earlier quoted context omitted.
We have some basic editor support, more is coming soon. Flow exposes several commands that are useful through an editor, like type-at-pos (give it a position, it gives you back the inferred type), suggest (give it a file, it dumps out an annotated file), autocomplete (gives you suggestions at a given position), etc. Also, we require annotations at module boundaries, so you're modules are going to have well-typed inte…
I strongly agree with module typing (and being more relaxed within). Because of caller dependence on modules, the difficulty of changing static types becomes a benefit. Plus, they need to be documented anyway; and tooling support helps use they as if they were primitives. As others have said, I love the approach of inference giving static type benefits, for free. If you get tooling support, at no extra work, why not…
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#279Earlier quoted context omitted.
Is this a serious post, or are you being sarcastic? I honestly can't tell. JS the language of the future? Why? It has probably the worst gotchas of any language I've coded in, it's verbose, and weird scoping. Nor is it especially nice to optimize for/with. I can certainly see being stuck with Javascript (just like we're stuck with the x86 instruction set even if simpler alternatives exist), but I'm not sure it's some…
The bad parts are there, but as of today it's a very powerful language that runs on every browser (hence every computer in practice?) with massive community support.
Oooh, there's many more computers around you than you think ;-) Nearly every modern piece of electronics. Many don't run browsers. For instance your washing machine has an OS, but it probably doesn't run Javascript. Same goes for your car, washing machine, dishwasher, microwave, central heating system, stereo/hifi, etc. And of course the more obvious "non-PC computers" like routers, printers, scanners, TV (might actually run JS if it's "smart" and has a browser), computer monitor and who knows what else. Coffee machine. The "fancier" it is (for a rather low barrier of "fancy"), the more likely it is to have a chip in it that runs some firmware/OS something, equal in power of what people ran as desktop personal computers a few decades ago.
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#280Earlier quoted context omitted.
Server-side js has that already. On the clientside it would be useless.
What about p2p?
Imagine your on your favourite social network that used a JS based encryption in a p2p chat to your friend. On that same page advertisers are pushing content to you. That content could be a malicious JS file which can eavesdrop on your conversation, all the while you think its encrypted.