TypeScript and related make a lot of sense for very large projects/teams because static type checking can be VERY useful, and the lack of a statically typed language choice for in-browser programming is a large weakness of the web ecosystem. So TypeScript is a tremendous advantage to have in the toolkit, and a much saner approach than older heavy-weight options like GWT.
I think it's telling that a lot of companies with the most mature products (Facebook, Dropbox, Asana) eventually resort to optional static typing in their products, whether that means extending their runtimes (e.g. Hack) or using a transpiler like TypeScript.
(Also I don't think optional static typing has gotten off the ground in Python land, or adopted in production at Dropbox?)
I used to use Coffee Script, which I still like, but ES6 clearly made Coffee Script less relevant. Typescript value is clearly in the type annotations and the support for ES6 ...
Another problem with Coffee Script is the fact that it evolves way to slowly and it is unlikely to support most of ES6 features because its core maintainers are clearly not interested in adding significant features. In fact that the main issue for me. Both Backbone and Underscore suffer from the same issues.
I see that a lot and find it highly subjective. I don't find es6 useful at all and will stick with coffeescript for the foreseeable future but that also has to do with my reasons for using it.
Better - it removes that ability for deliberate bad behavior by devs.
That said - I prefer JavaScript + Flow as thats a much more native solution which means you don't need to learn a pseudo language first.
It looks close to that, yes. However Flow can be also implemented via comments to native JS so... TS can't do that.
In which case...
> it's just as "native" as JavaScript + Flow annotations
is wrong. TypeScript requires a transpilation step. Flow doesn't. It can do, but it's not required.
I may have been a little harsh with the "pseudo-language" but I'm not sure what else to call something that is designed to be transpiled into the right language. It's not higher-level, it's sort of... a companion language I guess.
- Writing JS gives me a better feel for how the language actually works
- I like the line number in the JS I'm debugging to equal the line in my source code
- There's less magic to understand & deal with
- CoffeeScript automatically returns the last line of a function, and I don't always like that
Only because you know it better...
> - I like the line number in the JS I'm debugging to equal the line in my source code
Source maps.
> - There's less magic to understand & deal with
https://medium.com/@c2c/nodejs-a-quick-optimization-advice-7...
> - CoffeeScript automatically returns the last line of a function, and I don't always like that
Use explicit return then.
Fortunately, most everyone else seems to understand what Coffeescript is, and thus they were able to grok my meaning.
> 3 == "3"
true
> 3 * "3"
9=== does no type coercion. You can also coerce types manually. JS is not statically typed, but it is typed.
> A language is typed if the specification of _every_ operation defines types of data to which the operation is applicable, with the implication that it is not applicable to other types.
For a language to be typed, both the data must have a type and the operations must have a type specification.
> "a" * "b"
NaN
In a dynamically typed language, that specification is enforced at runtime. > true / false
Infinity
In a statically typed language, that specification is enforced by a compiler. > setInterval(function(){ console.log("hi") }, "later")
> hi
> hi
> hi
> hi
...
As far as I can tell, JavaScript doesn't concern itself with any of that. It's not typed.Javascript is typed, it just makes a lot of crazy decisions about what operations an operator does.
Javascript's type coercion leads to some wacky things like
> [] == []
> false
But it's actually all perfectly consistent once you understand what the compiler is doing with type (and JavaScript is compiled, not interpreted). == is an operator that will always try to coerce its operands to numbers, but the way it gets there can be circuitous.
You can specify type in JavaScript and avoid implicit coercion, you can use type constructors (generally worse) or certain unary operators. Ex:
> var foo = "12"
> var bar = +foo - 5; //+ explicitly converts foo to a number