News for hackers. Stuff that matters.

avik

Re:React Native is now open source on Thursday March 26, 2015 @03:02PM (#9272272)
It is with Flow.
Re:Facebook Launches Flow, Static Type Checker for JavaScript on Wednesday November 19, 2014 @11:24PM (#8634423)
Still early days but the reception has been strongly positive. We may be a biased bunch but we like our code mostly statically typed with the flexibility provided by dynamically typed languages. A large part of this culture is due to the immense internal success of Hack (http://hacklang.org/).
Re:Facebook Launches Flow, Static Type Checker for JavaScript on Wednesday November 19, 2014 @06:25PM (#8633382)
The source also has an emacs plugin, named flow-types.el
Re:Facebook Launches Flow, Static Type Checker for JavaScript on Wednesday November 19, 2014 @06:24PM (#8633376)
It does care about prototypes. So it checks for inconsistencies between methods added to a prototype and their uses. The tradeoff is that for dynamically added properties, it doesn't always remember where they are defined and where they remain undefined (it knows they are defined "somewhere").
Re:Facebook Launches Flow, Static Type Checker for JavaScript on Wednesday November 19, 2014 @06:21PM (#8633369)
Haha, yeah Hacker News didn't treat me well yesterday, so I'm trying to go through questions now and reply to them. :) Thanks for noticing!
Re:Facebook Launches Flow, Static Type Checker for JavaScript on Wednesday November 19, 2014 @06:20PM (#8633357)
If you can feed inferred static types to something like Google Closure Compiler, you do get performance benefits.

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 on Wednesday November 19, 2014 @06:14PM (#8633320)
Yes, so the conclusion one might draw is that if your code is implicitly typed, it will run fast as well as probably do well when run through a static type checker.
Re:Facebook Launches Flow, Static Type Checker for JavaScript on Wednesday November 19, 2014 @06:11PM (#8633312)
One obvious thing to try is to use Flow's type inference to emit GCC annotations and see whether those optimizations kick in. (Of course, Flow can also try to replicate whatever GCC does, but that will take some time. No reason not to, though.)
Re:Facebook Launches Flow, Static Type Checker for JavaScript on Tuesday November 18, 2014 @08:26PM (#8627627)
Yes, it does. You can define object types like { x: number; y: string }, tuple types like [number, string], function types like (x:number) => string, etc.
Re:Facebook Launches Flow, Static Type Checker for JavaScript on Tuesday November 18, 2014 @08:25PM (#8627621)
We actually built this because we write a lot of JavaScript at Facebook, and we need a tool like Flow. So yes, we worked on it full-time, with "funding": our developers like to move fast, Flow helps them do that.

(It's a different matter that we would have done this on our free time anyway, because it's so much fun!)

Re:Facebook Launches Flow, Static Type Checker for JavaScript on Tuesday November 18, 2014 @08:19PM (#8627606)
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 interfaces that serve well for both documentation and stability.
Re:Facebook Launches Flow, Static Type Checker for JavaScript on Tuesday November 18, 2014 @08:15PM (#8627590)
The implementation is heavily influenced by Pottier's work on subtyping + inference. https://hal.inria.fr/file/index/docid/73205/filename/RR-3483...

Also, some techniques from Typed Racket (occurrence typing): http://www.ccs.neu.edu/racket/pubs/popl08-thf.pdf

Many other papers have influenced the design in some way or the other. For example, Abadi/Cardelli's theory of objects.

Re:Facebook Launches Flow, Static Type Checker for JavaScript on Tuesday November 18, 2014 @01:42PM (#8625479)
No, instead of complaining about 'x' having the 'any' type, Flow will actually try to infer a static type for 'x'. So in the best case there would be no errors (and in the worst case there would be actual errors to fix).
Re:Facebook Launches Flow, Static Type Checker for JavaScript on Tuesday November 18, 2014 @01:39PM (#8625464)
Yes, OCaml.
Re:Facebook Launches Flow, Static Type Checker for JavaScript on Tuesday November 18, 2014 @01:33PM (#8625406)
Hi, I'm Avik Chaudhuri, I'm one of the authors of Flow, and I'll be happy to answer questions.