Discovering a New Way to Create JavaScript

Over time, developers will gain an entire toolbox full of different computer languages. A fully stocked toolbox is a developer’s best defense against the ever changing tide in what’s popular and what’s not in the world of application development. Recently I learned about a new computer language called TypeScript. The amazing thing about TypeScript is that it’s a true superset of JavaScript. If you know how to write JavaScript, you already know a great deal about TypeScript. In fact, I wrote an article entitled, “TypeScript: A New Direction in Browser-Based Applications” that describes some of my experiences with this new language. The short story is that TypeScript compiles into JavaScript, so you start with TypeScript and its advantages and end up with JavaScript code that is ready for use in your favorite Web application.

Of course, the biggest question people ask me is why I need to know yet another language.  After 28 years I’ve collected knowledge of more than a few computer languages—some of which turned out to be turkeys, some of which were extremely useful for a limited time, and others that I still use almost daily. Experiencing new languages and understanding how they can make developers more productive helps keep computer science alive for me. If I had stayed with the original set of languages that I learned as part of my training in college, I would not only be bored to tears, I’d be unemployed. So, if nothing else, learning about TypeScript is an adventure for me.

Adventures are better when they’re productive and interesting. TypeScript is interesting because it actually does improve on a language that’s really popular. You gain the advantages of using a compiler and static typing (amongst other things). For me, the use of the compiler is the biggest advantage because working with a compiler makes it possible to locate and fix the sort of simple errors developers make when tired. There have been more than a few times where a seemingly simple problem has kept my JavaScript application from running as it should and I later found that the problem was something that a compiler would have found in an instant.

Finding mistakes fast and easily, especially when you’re tired, is a real productivity booster. If I can code efficiently for another hour or two because I have a compiler helping me, I can produce more usable code than other developers. In the end, no one is going to care that I used a compiler to produce my JavaScript code. All that anyone is going to care about is that I produced more lines of code in a given time-frame than other developers using older techniques that don’t involve using a compiler. When you use TypeScript, you gain a productivity advantage over other developers.

TypeScript is available using the Node.js Package Manager, a Visual Studio plug-in, or by compiling the source code for your particular environment. My personal favorite is the Node.js Package Manager because it lets me work at the command prompt without having to worry about a particular IDE. I simply set up Komodo Edit to work with the new environment. Since I already use Komodo Edit to create my JavaScript applications, the environment is a good fit with TypeScript as well. There is no actual TypeScript support in Komodo Edit now, but people are talking about it. Of course, you’ll have your favorite environment and working with a new language like this always presents some challenges at first.

If you do try TypeScript out, let me know what you think of it. Do the features that TypeScript provides today make working with a new language worthwhile? Let me know your thoughts at John@JohnMuellerBooks.com. Also, keep your eyes peeled for more posts about TypeScript because this really does seem like an interesting and productive language!