TypeScript Won
medium.com
medium.com
But each time i re-read this post, the cohesive point that pops out most is that this post is basically a Donald Trump speech about Typescript.
The claim is that it's bigger, it's better, and everyone else is a bit sad. It disingenuously claims that it's not about about competition and then literally ends with "Typescript Won".
So, lemme offer some rhetorical advice:
1) pick to a POV & stick to it. It's a competition or it's not. You either think it's worth highlighting how much better Typescript is over other technologies, or you don't.
2) Most of the points made in the post aren't assertions about the benefits of Typescript or the decisions it makes. Not everyone agrees that the existence of a static type checker is an unqualified benefit (and there are many dimensions to that conversation). If you want to make the assertion that Typescript makes your life easier/better because it has a type checker, assert the benefits of having a type checker (and the decision making for AngularJS's adoption of Typescript on the basis of having a type checker could use a citation).
3) Related to 1., this post comes off as MEGA passive-aggressive because you keep on mentioning how much you also love other technologies at the same time talking about how they are inferior to Typescript on a variety of shifting bases. Because of that you're not telling a cohesive story about Typescript. You're just talking about how you think other technologies are bad.
The rest of your comment I agree with.
Comparing TypeScript to transpilers in the same space, like Flow and Dart makes sense. They're trying to accomplish similar goals at least.
[1] People will always still want to shave bandwidth, and the new hotness is Tree Shakers which shave bandwidth and computation/JIT time for the browser...
Plus, even a bunch of dev workflows are increasingly using tools like gulp-watch in the background of their refresh cycle (for whatever reasons), and Typescript's watch support has gotten very good.
After modules there's async/await and after that there's plenty more future to discover...
Also, optional type checkers throw away a lot of the upsides of type systems (safe refactoring, type-aware optimizations, useful generics) so they're kind of a worst-of-both-worlds solution.
Having just converted a bunch of pure Javascript to Typescript, and writing new code in Typescript, this hasn't been an issue.
> Also, optional type checkers throw away a lot of the upsides of type systems (safe refactoring, type-aware optimizations, useful generics) so they're kind of a worst-of-both-worlds solution.
I'm not sure what you mean by "throwing away safe refactoring" but yeah, you don't get the performance benefits or reified generics (not that it's particularly useful). That said, it's not like you derive any performance benefit from Java generics either.
Here's the actual download charts if you are interested: https://twitter.com/thejameskyle/status/725344218411986946
Source: - babel-core: http://npm-stat.com/charts.html?package=babel-core&author=&f... - typescript: http://npm-stat.com/charts.html?package=typescript&author=&f...
Also if you want types with Babel, use Flow– which is arguably a much better type system anyways.
I agree that Flow currently the superior type system (and, unlike TypeScript, not a complete nightmare to set up if you're wanting to use Babel/Webpack instead of manually running file builds through your editor like it's 2002), but TypeScript has significantly more momentum behind it making it a much more practical solution for basically anyone who doesn't currently work at Facebook. There are also several exciting new features coming to the type system that brings it closer to parity with Flow:
Non-nullable types: https://github.com/Microsoft/TypeScript/pull/7140
Control flow type analysis: https://github.com/Microsoft/TypeScript/pull/8010
I wish TypeScript tried to better-integrate with the greater JavaScript ecosystem and stop acting as a language of its own. Thankfully, the "es6" target gets it pretty close (I think it still compiles some es7 features, meaning you can't have Babel handle everything yet), and the non-standard module syntax seems to be a thing of the past.
I hope the gap can be bridged between the TypeScript and Babel communities, so that TypeScript can one day be shipped as a Babel transform, same as Flow.
Why? Besides, kinda ironic you point out the lack of reasoning in the article, then making a bold claim on your own providing no arguments.
No, if this community wants to act like a bunch of 12 year olds then that is their prerogative, but I'm not going to be part of it.
Again, I'm more than happy to talk about this anywhere else.
I recently built a Babel plugin that solves a lot of my module import pathing issues (namely the `../../` hell)
https://github.com/AntJanus/babel-plugin-namespaces
This and other plugins are just not possible on TS. The best way to look at Babel vs TypeScript is to realize they do different things. As far as Babel ES2015 transpiling vs TypeScript, maybe TS wins out. But Babel is a whole platform for transpiling. In fact, you can use both Babel and TypeScript together!
I haven't used it for any large projects yet (couple toy ones) but seems pretty legit. Based on my anecdata, people who have used it at scale seems to like it.
I can't tell if that's because they're still in the honeymoon phase or if it really is a step forward for the long term.
As a language, though, it still leaves a lot to be desired. Things like type guards and null annotations are like the methadone to the vastly more addictive pattern matching and options that I can no longer live without, and promises/callbacks are vastly inferior to futures. I would rather use Scala.js or Elm, but the ecosystems pale in comparison and trying to work in what is effectively an abstraction layer (and leaky at that) makes life really difficult. So I stick with Typescript.
With the latest Node releases and modern browsers supporting generators today, you can target ES6 and use async/await today if you can target those environments.
https://blogs.msdn.microsoft.com/typescript/2015/11/03/what-...
The tsconfig.json file does not allow for glob-type inclusion of files, or even inclusion of directories. However, you can exclude entire directories. So if I want to simply compile everything in the "src" directory, my best option is to exclude every other directory.
JS doesn't have namespace scoping, and therefore everything has to be explicitly scoped. So if I create `my.awesome.Date`, just `Date` means JavaScript's `Date`, and I have to put `my.awesome.Date` to get the new type. Typescript adds namespaces and scoping rules, so that anything in the `my.awesome` namespace or any namespace below it will see `Date` as `my.awesome.Date`. And there's no way to explicitly reference the global scope, so within those namespaces the new type completely and irrevocably shadows the original JavaScript type.
Also in JavaScript, unless I overwrite the original `Date` type, I can always explicitly scope it by saying `window.Date`. But TypeScript doesn't define `Date` within the `window` type, so I can't use that out either.
Because Date is a data type, not every browser may attach `Date` to the global `window` object. I can't think of one that does not, but it's one of those cases where JS has always been ambiguous.
That said, Typescript is more than happy to let you `(<any>window).Date` assert your way to that global. Or if you feel particularly strongly about this, you could in increasing order of strength of opinion: 1) add .d.ts file somewhere augment window yourself with Date, 2) fork the lib.d.ts and use your own instead of the default, 3) send a PR to Typescript adding it to the default lib.d.ts and see if they have a stronger reason for it not being there beyond it just being ambiguous in the JS language/spec/library.
Yes, and in the transpiled output I will see `Date` turned into `my.awesome.Date` for files within the namespace scope. As I said, JavaScript is always explicitly scoped, so unless you shadow it with a local variable or overwrite the original, you can always access it. So I could easily write `my.awesome.Date` in JavaScript without shadowing the native `Date`, but I cannot do that in TypeScript because of the namespace scoping rules it adds. Which, pains of using TypeScript being the original prompt, seemed quite relevant.
You can mix and match dynamic stuff with Typescript, depending on your compiler options, it'll treat non-typed things as if you were writing regular JS.
I always turned on 'do not allow 'any' types' because I wanted everything typed.
As far as C#... there are enough minor differences for it to be rather annoying if you have to jump back and forth every second day. C# is vastly more powerful and convenient as a language to Typescript, though. I'd write C# in the browser if it were a de-facto option, and I used to write and love Ruby. C# has all the functional stuff I doted over in Ruby, and it's all typesafe!
Arrays are no longer bivariant, and haven't been for at least a year. They are still covariant unfortunately.
I was using Visual Studio Community so I had all the benefits of intellisense (which is a big benefit), and I was able to manage a fairly complicated bespoke canvas thingo that suffered a few major refactorings - which I was able to perform with confidence due to the type checker.
The massive list of bundled typings and 3rd party typings makes it much quicker to pick up a new API or remind yourself of one you haven't used for a while.
I now write C# day to day and I find I don't spend the majority of my day alt-tabbing to and from documentation web pages as a result.
So... any bad things to say? None at all off the top of my head. I'm a huge convert, and not because 'it's nice' or 'it's pretty' but because it's like wearing the Iron Man suit when it comes to programming. It's helped me be more productive on non-trivial projects.
1. partial application (bind is typed as 'any')
2. sum type destructuring
3. issues with recursive type definitions
But the Typescript team add new features very quickly so I wouldn't be surprised if these issues are solved in the future.
Other than those nuisances, I've grown to like using TypeScript a lot.
The above sounds negative but TS is still the best bet right now imo. Some people will prefer Elm or Purescript for better type systems but I like staying close to JS.
With regards to types: TypeScript has only recently added support for any kind of Algebraic Data Types whereas Flow was built upon Unions and Intersections from day one. That to me speaks to their priorities.
https://blogs.msdn.microsoft.com/typescript/2015/01/16/annou...
https://blogs.msdn.microsoft.com/typescript/2015/09/16/annou...
They seem to be moving at a decent, agile pace to improving/expanding upon the algebraic sides of the type system.
Thank you for correcting me.
(It will be opt-in as Typescript follows a rule of increasing strictness via compile options to support the spectrum of JS needs, but also as it will not be entirely backward compatible with existing type definition files and will need some effort among typings authors.)
I prefer the idea of Flow as well but tooling and community is not there yet
The fact that last time I checked, it wasn't able to consume TSD signatures from third-party libraries (or offer an equivalent system with a significant amount of libraries) is a much bigger issue IMHO.
When I bring up the latest and greatest (eg. Flow) it doesn't actually work on Windows because Windows is as I see it an after-thought for a lot of the Open Source world.
But I've brought up this exact problem (the lag in tooling) to .Net/Windows devs before and they've told me I'm wrong and that they've got all the latest and greatest dev tooling like everyone else.
Consider being in the situation of being in charge of a large coffeescript codebase, today. No thank you.
In particular I like how readable and clean CoffeeScript is when you have a long series of callbacks.
Back in my Backbone + CoffeeScript days, I reimplemented Rails style has_many/belongs_to "class methods" on Backbone.Model, and it was incredibly useful. But would've been doubly so if I could have had it statically checked somehow.
This whole article has a very "Wow, all other languages except for the one I've invested time in really suck!" feel to it. The arguments presented are shallow at best, rely on short-term data, mostly just popular trends of what people are talking about/searching for.
There's not any empirical evidence that I've seen in this article that suggests any language is better than any other language.
TypeScript seems to be rather big for MS. But FB mostly pumps money in Babel and React at the moment...
I continue to watch Typescript because I think it has its place and certainly is worth knowing / using in certain projects. I really appreciate the .d.ts/DefinitelyTyped (files which provide Typescript static types for javascript libraries) that are available, I am able to mostly convert them to ScalaJS facades programatically which gives me nice code complete in ScalaJS.
One area I think Typescript outshines ScalaJS is if you have a large existing Javascript codebase, or are a Javascript programmer looking to incrementally improve your codebase / language knowledge Typescript is the best step in that direction.
However if you are going `full stack`, with high performance requirements on one side, and a browser on the other, right now I think Scala is the best option. That opinion might change in the future with web-assembly (then perhaps back again e.g. scala.native ).
ES6 is non-negotiable. I understand the basic premise behind Typescript. Would I "switch" from Babel to Typescript and get arrow functions and string interpolation through Typescript somehow?
* A language, superset of ES6 that adds optional types
* A compiler (like Babel) that will take your Typescript code, check if the types are correct, remove them, and transpile the non-ES5 parts of into ES5 (just like Babel).
So if you want to use Typescript-the-langage, you need Typescript-the-compiler and you will no longer need Babel.
If you don't care about that, it's pretty much the same except async/await are not there yet. In Babel you could also use ESX features before any kind of approval while TypeScript only implements features approved (afaik).
Although every big project I take these days I prefer to write in TypeScript, I would honestly not use it if I have a small static landing page with an AJAX ticker or something. It would be overkill.
The whole point of Babel is to be a stopgap, so it's not surprising that its usage is declining. Babel is not a language.
TypeScript is currently popular but popularity in JavaScript never last long. The cycle is:
* A library that comes out that solves a problem with the previous iteration.
* The new popular library has some different problem but people ignore it because the new cool thing is still fresh in their minds.
* People become annoyed with the popular library and someone makes a new library that fixes the problem with the popular library. It looks a lot like the original library that popular library replaced.
* Cycle repeats itself.
It's backed by M$ and the Github repo is super active, especially in langauge proposals. This will be around for a while.
The JavaScript hype cycle has no escape hatch. All that go up, must come down. Some things just last a little longer than others.
Exactly the problem. Like all other Google projects, they bailed on it.
Ditto for Closure which is actively developed (and is among the best libraries in ES6 features) but also lost the hype cycle to Uglify.
I think it's a very pointless thing to pick a winner. It's not a popularity contest. You will be able to tell that some technology is "lost" or is over, when the popularity will be declined to the 0.0.1 alpha release state.
However I always bet on technologies that are standardized rather than maintained by a company. Not a fail safe approach, I know, but that's the way I minimize risk.
http://zenoverflow.com/2016/04/27/platform-of-the-browser/ - my response to TypeScript Winning
Class-based vs prototype-based, classes will always win. JS is terrible, TypeScript is only very slightly better.
Dart's core team is absolutely world class, and the language is already highly capable.
Hmm.
Pointing out that CoffeeScript is on the decline because Google Trends for it once peaked and has since declined?
Hmm.
Failing to consider that TypeScript might be at a similar peak and is due a similar decline?
Hmm.
Hmm.
next month people will want memory protection in JavaScript and JavaScript developers being JavaScript developers will create a new project from scratch with new syntax, just like Babel did from coffee and like typescript did from Babel.
meh.
this is all needed because you have a team that doesn't know how to agree on coding style or something. yes, it would be nice to have type errors detected before runtime. but we have responsive devs so we never had those errors to begin with. and we're way past 80k lines. adding a transpiler would be more annoying than helpful.
Types (can) be helpful.
If typescript was simply type safety that would be one thing. It's definitely a lot, lot more than that.
Typescript is to .NET as Coffeescript was to Ruby. A bunch of developers who didn't know JavaScript and wanted to find the closest thing they could to what they already knew. And who really uses Coffeescript anymore? Stick with esnext to babel and the bright future JavaScript has ahead.
Coffeescript's future is diminished, presently (hah) - but ES6 only picked up a handful of magical features.