Glimmer.js: What’s the Deal with TypeScript?
Two weeks ago at EmberConf, we announced Glimmer.js, a component-based library for writing superfast web applications.
For example, CoffeeScript adopted
for..of loops to iterate over the properties of an object. Meanwhile, ES6 introduced its own
I have witnessed the intense amount of thought and care TC39 members devote to figuring out how to introduce modern language features in a way that is completely backwards-compatible. It involves dumping out all of the existing features and syntax on a table, and painstakingly moving them around until a compatible path can be traced through.
- Languages with totally different syntax and semantics, like ClojureScript, are difficult to debug, even when source maps are working perfectly.
But not TypeScript. TypeScript is different.
TypeScript is different because of how radically constrained it is.
.ts, and boom, you’ve got a valid TypeScript file.
From there, you can incrementally add type checking only where you think it’s necessary.
It’s easy for people to have a visceral negative reaction to TypeScript. Let’s be frank: a lot of TypeScript examples are nearly indistinguishable from Java.
But two points:
- All of that extra type syntax is optional; only use it if it’s bringing you benefits.
As you can see, we’re using cutting-edge ES2017 features like async functions, and the syntax is exactly the same across both. The only difference in the TypeScript version is that we declare the fields on the
And even these simple annotations quickly begin to pay dividends. For example, using a TypeScript-enabled editor like VS Code gives us detailed information about class properties, just by hovering our mouse over them:
“But I Still Don’t Want to Use TypeScript!”
“That’s what Angular said and look how that turned out.”
For example, here’s an Angular component in TypeScript:
emitDecoratorMetadata). Dependency injection is front and center in Angular, so they (very rationally) decided to use the types you’d write anyway to power the DI system.
After having used TypeScript for nearly a year, I have to confess: I never want to start a new project without it again.
Refactors that used to take weeks take days, sometimes less. And because refactoring is so much easier, cleanup that would never have happened becomes… almost painless.
Most of all, I continue to be impressed by the professionalism of the TypeScript team. In an ecosystem that can feel built on a house of unmaintained cards, TypeScript’s drumbeat of constant, iterative improvement is refreshing.
TypeScript is exploding in popularity and I think it will continue to only get more popular. As I finish writing this post, Felix Rieseberg’s post on using TypeScript at Slack is on the front page of Hacker News. I suspect that most people who try TypeScript will end up liking it.