4 ms·
Flow is a different language than JS. Keeping the .js extension doesn't make it a "close to JS" language. TypeScript and Flow are both supersets of JS
by msoad 10y ago
Flow is a different language than JS. Keeping the .js extension doesn't make it a "close to JS" language. TypeScript and Flow are both supersets of JS
- smt88 10y ago> Flow is a different language than JS How so? Isn't JS-with-Flow just JS with specially formatted comments?
- abritinthebay 10y agoThat's one option (my favorite and the simplest to use). But the "default" is annotated JS which is not dissimilar to how TS operates. I prefer Flow's syntax and if it wasn't for the annoying "you have to run a server to check code" thing... I'd use it a lot more
- jankassens 10y agoYou can use `flow check`, but the server has the benefit of giving almost instant responses even on large code bases by only revalidating a subset of the project.
- abritinthebay 10y agoYeah, there are ways to configure it to be better but it's just not... "nice" out of the box. Which is sadly important - for something so optional.
- ng12 10y agoBut Flow is actually a superset of JS -- without the types your code is perfectly valid JS, which is what actually happens via a simple Babel transform. Typescript is both a transpiler and a language, it's much further from pure JS. The actual advantage of this is you can drop Flow in any Babel project. With Typescript you need additional tooling.
- Touche 10y agoThey are both supersets. If you remove the non-JS features you have valid JS. But of course without removing it you have invalid JS. That's why both require tools. Sidenote that Flow does allow specifying types through comments but this is a bit of a second-class feature.
- ng12 10y agoSorry, let me try to be more clear -- because this is a very real distinction which does have practical implications. You can run Flow on ES code without changing it. If you have type annotations it will use them to help find errors, and you can use a simple tool to strip them out. The key thing here is that the "stripped" code is EXACTLY your source minus the type annotations. Typescript does not operate like this -- you cannot make assumptions about what the code looks like post-tsc. This is very important if you have some other tools, like Babel plugins, which operate on your code. You're likely to run into trouble if you want to use syntax Typescript doesn't understand or if a tool is doing some sort of code analysis. Typescript is a language but Flow is much closer to a linter.
- Touche 10y agoYou're describing a property of their compilers as evidence that one is a superset and one is not. That TS transforms your code doesn't make it not a superset. It would not be a superset if it didn't support some JS feature. If it didn't support extends or something.
- ng12 10y agoI'm not saying Typescript isn't a superset of JavaScript, I'm saying Flow is more direct superset in a way that's important. I'm more trying to clarify people who are saying Flow and TS are both supersets and therefore directly comparable. Specifically, the root poster's contention was that they're both supersets and therefore both "not JS".
- spion 10y ago