Live data from Hacker News

Facebook Launches Flow, Static Type Checker for JavaScript

code.prod.facebook.com

121–130 of 282 posts

Re: Facebook Launches Flow, Static Type Checker for JavaScript

#121
post #101

Earlier quoted context omitted.

That is a surprisingly hard question to answer. I think the key is that these projects actually provide value - they make things faster, more reliable, more scalable - whether that's the code's execution or the people writing the code (or debugging issues, or whatever). They generally aren't solutions seeking problems - they are responses to problems that exist. Engineers generally don't build things like this on the…

It sounds like there is enough slack in the schedule that teams can decide they want to spend non-trivial amounts of time on these projects. It's surprising to hear that anyone, even the companies with big budgets, are able to hire enough people to do this without the projects getting an official seal of approval and budget. Even just taking the time to document, package, and publish is non-trivial. It seems like the…

There is a degree to which scale makes it necessary to develop these sorts of projects. Losing 1% of productivity in a engineering group of 10 people might not be a big thing, but at 1000 people that's 10 full-time people worth of productivity you're losing. Dedicating 1-10 people for a few months or a year (or even two years) to remove that 1% productivity loss is clearly worth it.

Documentation costs productivity to write, but when there are many people who would be made more productive from it, it makes sense to do it.

I think "slack" is the right way to think about it. It isn't a free-for-all - the business still needs to run - but there's enough space to explore, to rewrite, to document, to polish, and so forth. That's where the magic happens - the unplanned and the unexpected things around that which you thought you were going to do.

Re: Facebook Launches Flow, Static Type Checker for JavaScript

#122
post #46

What a great tool. Facebook are absolutely killing with the last year or so with all of their open source contributions and releases. First HHVM, Haxl, React.js (amongst other things) and now Flow, this is fantastic. I am really liking how companies like Facebook & Google are concentrating their efforts on the web language of the future: Javascript. The support for JSX alone is a MASSIVE feature (expected given React…

It's hard for me to give appreciation but while Google have traditionally been tech leaders in web technologies: Facebook are doing really awesome stuff lately. It's not just React and this - it's also FLUX, HHVM, Hack, Haxl (Their Haskell libraries), contributing to writing a spec for PHP and other ventures. I'm interested in who is the driving force behind this open source change in Facebook, I don't recall faceboo…

> I'm interested in who is the driving force behind this open source change in Facebook, I don't recall facebook in behaving these way 4 years ago. [..] Can anyone find anything on a policy change that happened? They really turned around.

My guess is that Facebook was just much smaller 4 years ago, over that period its staff grew very quickly. And even today it has an order of magnitude less employees than say Google, Apple, Microsoft, etc.

Larger, more established companies have more opportunity to open source things on this scale.

Re: Facebook Launches Flow, Static Type Checker for JavaScript

#123
post #103
post #78

Earlier quoted context omitted.

Well, here are some things that it does that other tools don't: - It type checks JSX - It supports some ES6 features others don't (like destructuring) as the build step - It has union types (TS will get those soon, already in master) - It does a lot more inference and a lot more assumptions. It assumes you won't multiply a string by a number for example (although technically '10' * 5 is legal in JS). So it's opiniona…

I digress but... you're not wrong, but out of curiosity, I just genuinely wonder how often modern programmers really hit type errors on smaller projects (obviously not FB size). I don't think I've ever had a type cast bug in my js code, provided we don't include accidental nulls in that statement. So in my experience, if I were ever told that I now had to always use annotations, I would feel like I was losing flexibi…

In the large multi-contributor dynamically-typed codebases I've dealt with, type errors are very rare.

Re: Facebook Launches Flow, Static Type Checker for JavaScript

#124
post #115

Earlier quoted context omitted.

I find this type of work within companies (like google's famous 20% rule) an interesting contrast with non-tech companies. At a "normal" company if you attempt to spend time doing something of this sort, you'd get immediate pushback from higher ups who would likely say "this is not our core competency". With the secondary excuse being that they would not want to release any work like this for fear that it would help…

Different people find different things exciting/sexy to differing degrees. Some people like building stuff that others can see. Some people like building stuff that others will use. Some people like building stuff that makes other people build stuff faster. Some people like building stuff that is highly reliable, really fast, really scalable, or really efficient. Some people even find improving advertising really exc…

It is a great luxury to be able to work on what you like, especially as a dev. Unless you're a well-known person, I don't think it's that easy to work on what you like, even at google. At least not anymore. Hopefully you guys at facebook can keep the MBA's off your backs long enough to do more cool stuff!

Re: Facebook Launches Flow, Static Type Checker for JavaScript

#125

This is HUGE! Thanks to everyone at Facebook who worked on this. You guys are awesome. Also: The fact that this is written primarily in OCaml (as opposed to JS) is an excellent example of people choosing the right tool for the job.

IMO OCaml is the wrong tool for the job in this case (even if it is a better language for this sort of tool).

JavaScript has a weird ecosystem where it is extremely helpful to have all of your tools in the same language. browser-based IDEs, Node, portability, etc, and just one fewer runtime to juggle.

Same reasons why closure is awkward as a Java program.

Re: Facebook Launches Flow, Static Type Checker for JavaScript

#126
post #116

Or you can just use GWT which saves you from having to use javascript at all, and lets you write java (along with all its IDEs, type checking, code structure, and other benefits) which is compiled to highly efficient javascript: http://www.gwtproject.org/learnmore-sdk.html

"Java" which "compiles" to javascript is not Java. It's javascript with a ludicrous amount of syntactic sugar applied.

All the language features of java: generics, inheritance, type safety, interfaces, and soon to come: lambdas and other Java 8 features, are all supported. Plus your code is organized in java packages. So, I'm not sure you've ever tried GWT.

Things like multi threading which aren't possible in javascript aren't supported, but a lot of the JRE which is used in most code, does come out of the box. Its a huge improvement over regular javascript, anyway. And client + server code can be shared.

Re: Facebook Launches Flow, Static Type Checker for JavaScript

#127

What a great tool. Facebook are absolutely killing with the last year or so with all of their open source contributions and releases. First HHVM, Haxl, React.js (amongst other things) and now Flow, this is fantastic. I am really liking how companies like Facebook & Google are concentrating their efforts on the web language of the future: Javascript. The support for JSX alone is a MASSIVE feature (expected given React…

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 something I rejoice about. Javascript is like anti-Batman: a language we all deserve, but not one we need.

Re: Facebook Launches Flow, Static Type Checker for JavaScript

#128
post #46

What a great tool. Facebook are absolutely killing with the last year or so with all of their open source contributions and releases. First HHVM, Haxl, React.js (amongst other things) and now Flow, this is fantastic. I am really liking how companies like Facebook & Google are concentrating their efforts on the web language of the future: Javascript. The support for JSX alone is a MASSIVE feature (expected given React…

It's hard for me to give appreciation but while Google have traditionally been tech leaders in web technologies: Facebook are doing really awesome stuff lately. It's not just React and this - it's also FLUX, HHVM, Hack, Haxl (Their Haskell libraries), contributing to writing a spec for PHP and other ventures. I'm interested in who is the driving force behind this open source change in Facebook, I don't recall faceboo…

Facebook has been doing a great job with marketing their open source projects. It seems like every Facebook OSS project has a strong logo, beautiful landing page with good documentation, a distinct group of project champions within the company (with embedded recordings of their conference talks on the project site), mailing lists, IRC channels, and the projects are often exceedingly applicable to a large proportion of real world software projects.

Not to say that Google's OSS hasn't done much of the same, but AFAIK many of their projects fail on at least a couple of these points.

Re: Facebook Launches Flow, Static Type Checker for JavaScript

#129

What a great tool. Facebook are absolutely killing with the last year or so with all of their open source contributions and releases. First HHVM, Haxl, React.js (amongst other things) and now Flow, this is fantastic. I am really liking how companies like Facebook & Google are concentrating their efforts on the web language of the future: Javascript. The support for JSX alone is a MASSIVE feature (expected given React…

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…

Read the Good Parts of Javascript and get a JS linter. Javascript is a fine language if you do this.

Re: Facebook Launches Flow, Static Type Checker for JavaScript

#130
post #54

Earlier quoted context omitted.

You can't really use sum types as they are found in Haskell in Javascript. With Haskell option types you do a pattern matching and create a new binding for the non-null value but in Javascript you don't do that - you keep using the same object that you tested against null. case mx of Just x -> f(x) vs if (x != null){ f(x) } What you can do in a Javascript-like language is use union and intersection types. However, th…

What about function nothing() { return { match: function(cases) { return cases.nothing(); } }; } function just(x) { return { match: function(cases) { return cases.just(x); } }; } just(1).match({ just: function(x) { return x + 1; } nothing: function() { return 0; } });

Right, but now you're not using null. The question was how to justify the use of sum types for null... not whether or not they could be emulated in some non-idiomatic manner.
Post reply on HN