TypeScript & the Future of JavaScript

July 2, 2015

Blog | Development | TypeScript & the Future of JavaScript
TypeScript & the Future of JavaScript

 

ES6 is here right now, although we can’t use it yet.  So… what can JavaScript developers do to make our projects better? Two answers are emerging.  One is to write in ES6 and run it through a compiler that “transforms” it into ES5, the current version of JavaScript.  The other is to write in different language entirely, such as Dart or CoffeeScript (punny!) which can then be compiled into ES5.  Either way, you can write run-anywhere code, but work in a language with fewer pitfalls.

Learning a language takes time and mastering it takes even more time.  And writing in a language that writes a language (Dart-> JavaScript) means you need to know both languages, despite any claims to the contrary. Unless it’s a commercial product, or a popular open source tool, it’s better to avoid code that writes code. It’s too easy to write buggy code, which results in more buggy code.

Understanding JavaScript before learning a language that writes JavaScript is a far better practice. As every language has its own idiom and style, it’s important to know and use the style that is accepted or expected by the community. Here’s a helpful cheat sheet we found that will help you learn JavaScript.

With that said, I’m excited about TypeScript.  Developed by Anders Hejlsberg, Technical Fellow at Microsoft, TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. That’s right: JavaScript is valid TypeScript.  It works on any browser, server, OS and is Open Source. And the tools are very impressive.  You can write in ES5, or you can add ES6 features and compile down, or you can use the full TypeScript language, which gives you static types, interfaces, modularity, and of course it still compiles down to ES5.  In fact, it will compile to any version of JavaScript you want; just edit the config file. The takeaway? Write in real JavaScript and then add as much “magic” as you want.

Why This Matters for Developers

 

I’m so optimistic about TypeScript versus Dart or CoffeeScript because TypeScript aims to imrpove JavaScript, not leave it behind.  You can take or leave any part of the tool chain.  The end goal is to make it easier to write and maintain sophisticated JavaScript apps.  JavaScript wasn’t really designed to build large apps, so TypeScript fills in the gaps, but it’s still JavaScript.  Head over to the TypeScript Playground and see for yourself.

 

Why This Matters for Business

 

The lack of types in JavaScript can hinder development and debugging, and make it difficult to uncover bugs. TypeScript, however, provides the safeguard of a statically typed language, while harnessing all the goodness that is JavaScript. In addition to features like auto-completion and refactoring support, it also provides added tool support. Ultimately, this improves project estimate accuracy, increases developer productivity, shortens timelines, and helps to bring JavaScript projects in under budget.

Have you used TypeScript, Dart, CoffeeScript, or one of the ES6 transpilers?  What are your thoughts?

Dan Clouse

Senior Developer
Tags
  • JavaScript

Recent Work

Check out what else we've been working on