Decoupling your development from the shifting sands of JS support - across multiple browsers and platforms - is a dream come true, and a good enough reason alone to use TS.
Decoupling your development from the shifting sands of JS support - across multiple browsers and platforms - is a dream come true, and a good enough reason alone to use TS.
Ultimately, if you're going to program in JS then get comfortable in JS, rather than trying to make JS more like your favourite language.
That's probably why a lot of people are excited about typescript. It basically is JavaScript, but optionally annotated JavaScript. It's not a new language.
(2) Transpiling from a whole different language means you have to port the standard runtime, otherwise you'd lose portability and familiarity, which are the two key advantages of transpiling from another, widely used language. Also, as JavaScript often runs in the browser this means downloading the runtime.
(3) The more different the two languages are, the more likely you'll run into surprising situations where feature X in language Y cannot be implemented in its original form in JavaScript, causing subtle incompatibilities between Y code written for the "original" Y compiler / interpreter and Y code that was meant to be transpiled.
(4) As someone else mentioned, TS is almost a superset of JS, which means mixing in JS code into TS code is much easier.
(5) What is a real language anyway?
High-level languages look nothing like machine code, but we still compile them to it.
> Transpiling from a whole different language means you have to port the standard runtime
That's true, but it's not a reason not to use a good language instead of a horrific one.
> The more different the two languages are, the more likely you'll run into surprising situations where feature X in language Y cannot be implemented in its original form in JavaScript
I contend that any feature of a Turing-complete language can be implemented in JavaScript.
> As someone else mentioned, TS is almost a superset of JS, which means mixing in JS code into TS code is much easier.
'I still get to use JavaScript' doesn't sound very appealing. But, of course, many high-level languages offer an escape to assembler: a high-level language compiling to JavaScript can offer an escape to JavaScript.
> What is a real language anyway?
Haskell, CaML, Lisp, Python, Go — not JavaScript, though, which is an embarrassment to our profession.
Ask HN: If TypeScript is so great, how come all notable ReactJS projects use Babel? https://news.ycombinator.com/item?id=12537614
Compatibility with JavaScript source (instead of libraries) is a disadvantage. The most dangerous parts of TypeScript are the JavaScript parts: arithmetic, bracket notation, etc.
I guess TS being a superset of JS itself might be an advantage...otherwise it is still a new language designed for web browser programming unlike Java.
I suppose it is a fair question why they didn't just use C#.
ClojureScript uses the Closure(sic) compiler from GWT to compile Clojure/Java to JavaScript (not that I defend this technological train wreck).
> I suppose it is a fair question why they didn't just use C#.
This would have been superb, but I think Microsoft wanted to show that they "get" web developers; just mentioning C# causes the JS pundit get jittery because someone wants to limit the amount of write-only code he is able to spit out.
false.
Closure does not compile java to js and closjurescript does not use any tech from gwt.
Clojurescript compiles to JS itself and then uses the Closure compiler (which is an incredible piece of tech) to compile js to js (not transpile, but actual compile).
And of course Dart.
Actually it did catch on in the enterprise world, just like Typescript. Will Microsoft be as "dedicated" as Google regarding its language? wait and see.
I love TS, and am finding more and more ways to inject it into old codebases. However I remember what happened with coffeescript and am sure to always clearly document my build pipeline in case someone needs to move away from TS in 5 years.