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…
Facebook Launches Flow, Static Type Checker for JavaScript
261–270 of 282 posts
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#262Re: Facebook Launches Flow, Static Type Checker for JavaScript
#263Earlier quoted context omitted.
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…
I do hobby level small js projects, I make type errors quite often, but they are easily found the moment I run the tests/the app. I would prefer to find them at compile time, but it's not a big deal. Interstingly it's almost always the same kind of type error- accessing nested maps/arrays and forgetting to go deep enough before I call some method on the elements in that collection. I can't remember one example of typ…
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#264Earlier 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…
From http://steve-yegge.blogspot.com/2007/02/next-big-language.ht... - Rule #1: C-like syntax - Rule #2: Dynamic typing with optional static types - Rule #3: Performance - Rule #4: Tools - Rule #5: Kitchen Sink - Rule #6: Multi-Platform This tool provides #2 for Javascript, the NBL.
Makes much more sense, but I am going to forgive him.
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#265There's some tremendous effort being poured into making a crippled language like javascript usable, but when talking about solutions for maintainable frontend code, I'm more excited about compile-to-js languages like haxe [0], purescript [1] or ceylon [2]. The caveats I heard about transpilers often boil down to difficulty of debugging and lack of libraries. But with the amazing browser dev tools we have, debugging p…
I think Dart seems to be a great language and IE, Firefox and Safari should have implemented it years ago, but they didn't. Now I think TypeScript is a great addition to javascript and I hope they build it into the browsers but I suppose they won't (maybe EcmaScript 7 will have some parts of TypeScript in it, or parts from AtScript from Google).
By the way, you probably still want minification and concateneted files when you create js from other languages. That stops me from using them, I would have many levels of tools between my source code and the production code.
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#266Earlier quoted context omitted.
I don't think you're seeing my point. You may be coding java, but none of the tangible benefits of java over javascript actually translate, because you're actually writing javascript, with all of the warts and limitations and weirdness therein. The javascript exported will not be truly type safe, because javascript is not, and cannot be. It may appear to act like it, within the context of the code when run as predict…
The point is, that you don't have to deal with any of those issues with javascript. I've been using GWT for over a year, and I've never had to dive into the compiled javascript to debug something. I only ever edit my java code, and I compile it, that's it. Its exactly the same as your C code compiling to assembly, or the java code compiling to bytecode. You never have to look at the compiler's output.
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#267Earlier quoted context omitted.
I do hobby level small js projects, I make type errors quite often, but they are easily found the moment I run the tests/the app. I would prefer to find them at compile time, but it's not a big deal. Interstingly it's almost always the same kind of type error- accessing nested maps/arrays and forgetting to go deep enough before I call some method on the elements in that collection. I can't remember one example of typ…
And in a large app it is hard to know if all relevant code has ran. Finding pieces that uses the code you just changed is much easier in static languages. We might not go to a fully statically typed javascript but supporting optional typing seems like a really good idea.
BTW it's funny how many times late binding was reinvented in j2ee ecosystem :)
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#268Can someone explain in simple words what is the problem that this would fix? I've never felt the need for this, why should I care?
It makes it easier to catch some types of bugs without having to run the code. http://en.wikipedia.org/wiki/Type_system#Static_type-checkin...
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#269Earlier quoted context omitted.
If only to remove syntactically invalid type annotations, I guess. Strong typing is not incompatible with the absence of run-time typing information, due to the magic of type erasure.
Type erasure is only safe if the whole program is statically typed though - you are still going to need to use runtime checks if you want to interface with dynamic code.
For instance, you could imagine a function calling into some unknown api, where we would need to constrain the type of the variable to the expected one to avoid `any` being applied to it. While the library files do provide typing of external dependencies, this doesn't protect you from bugs in those libraries! The same applies to api's that are explicitly typed as `any`, but which should return a certain type.
Having Flow add a dynamic assertion on the type here would allow the rest of the program to remain type safe, knowing that a violation is guaranteed to halt execution.
While dynamic strong typing is also used at Facebook, we're not quite ready to launch this as an extension to Flow.
Re: Facebook Launches Flow, Static Type Checker for JavaScript
#270Earlier quoted context omitted.
The point is, that you don't have to deal with any of those issues with javascript. I've been using GWT for over a year, and I've never had to dive into the compiled javascript to debug something. I only ever edit my java code, and I compile it, that's it. Its exactly the same as your C code compiling to assembly, or the java code compiling to bytecode. You never have to look at the compiler's output.
I think Google created Angular in part because of some problems with GWT. Of course some developers still uses GWT but others have switched to AngularJs and seems to think it is much more productive. And some combines Dart with Angular which really looks interesting.
Also, angular and dart are slow as shit compared to GWT.