BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

Community Questions TypeScript and Compile-to-JavaScript Languages

by Harry Brumleve on Oct 25, 2012 |

Microsoft generated a stir in the JavaScript community with the introduction of its programming language TypeScript. This recent offering from Redmond renders JavaScript by interpreting a proprietary, type safe language, allowing a developer to leverage JavaScript functionality while reducing the need to master JavaScript itself. The software community has had mixed reactions to this new language, with some embracing TypeScript’s way of writing type safe JavaScript and others questioning the existence of the entire compile-to-JavaScript genre.

Initially, much fanfare from .Net-friendly news sources such as DevProConnections accompanied TypeScript’s release. Michael K. Campbell, a regular contributor to the DevProConnections website, offered a fair, but positive stance on TypeScript’s future. Campbell concludes that this style of application development represents the logical maturation of JavaScript, and TypeScript should be seen as a formal announcement to safely take JavaScript from the browser and introduce it to the desktop and back-end services.

I can't help but think there's a bright future in store for TypeScript. I'm particularly excited by TypeScript's future when I think about how web development trends are moving increasingly toward architectures that heavily leverage JavaScript for dynamic in-page rendering against API-enabled back-end web servers such as Microsoft's ASP.NET Web API framework.

Developers wishing to take advantage of JavaScript without having to invest a significant amount of time have found other reasons beyond type safety to adopt TypeScript. TypeScript offers a class-based object-oriented programming model which appeals to developers of C# and Java-style languages. Danny Tuppeny, a Cheshire, England based software developer, writes that this feature of TypeScript allows him to leverage JavaScript without having to master the underpinnings of the prototype-based object-oriented language.

I don't know a huge amount of Assembly or IL. Sure, there might be situations where knowing more of them would be useful, but is it really worth the time investment when I could instead be improving my C#/other skills that I use every single day?
Does it matter if I can't type JavaScript without looking it up to hook up subclass prototypes in JavaScript if TypeScript can do it for me? No. Does it help if I understand the generated code? Sure. Is it a requirement? No. All that matters is I understand how it behaves and any limitations of it. The same way I don't need to understand 100% of the IL generated when I write C#.

However, TypeScript is only the most recent entrant into the genre of compile-to-JavaScript development languages. Dart was introduced last year as a way to circumvent the shortcomings of JavaScript and enable a more robust and productive development experience on the web. While both languages share a more robust programming syntax than JavaScript, including type safety, the similarities between the two languages stop far short of having either one labeled a clone of the other language.

Scott Hanselman, a Microsoft Architect in Web Developer Tools, not only promotes the case for TypeScript, but also questions the need to compare it to Dart, noting that they are developed in a different manner and are fundamentally different at their core.

People have compared TypeScript to Dart. That's comparing apples to carburetors. TypeScript builds on JavaScript so there's no JS interop issues. Dart is a native virtual machine written from scratch. Dart interops with JavaScript...but it's not JS. It doesn't even use the JavaScript number type for example.

Shannon -jj Behrens, a developer on the Dart team, furthers this distinction by welcoming TypeScript to the family of compile-to-Java languages. The Dart team sees TypeScript as an adopter of older and buggier technology due to its reliance on JavaScript, a competitor which they believe they will soon surpass. This may explain their encouragement of Microsoft to continue to build around the JavaScript codebase.

Now that we’ve had a chance to take a look at TypeScript, the Dart team would like to welcome the TypeScript team to the neighborhood. If you already have a large JavaScript codebase, and if you already use Visual Studio, we think that TypeScript could be a great addition to your project.

But not everyone embraces the idea of replacing JavaScript or even rendering JavaScript via a different language. Nicholas C. Zakas, a web software engineer and blogger for NCZonline.net, questions whether or not compile-to-JavaScript languages are even worth learning; when a relatively similar investment in JavaScript can yield the same result.

I see compile-to-JavaScript languages as a barrier to that goal. We should be convincing more people to learn JavaScript rather than giving them more options to not write JavaScript. I often wonder what would happen if all of the teams and companies who spent time, energy, personnel, and money to develop these alternatives instead used those resources on improving JavaScript and teaching it.

Marco van Hylckama, senior UI prototyper for Yahoo, is echoes the feelings of many JavaScript developers who would prefer the industry to focus on existing technologies simply leave JavaScript development to the JavaScript language itself. Via his Twitter account, Hylckama questions the need of TypeScript and the entire category of compile-to-JavaScript languages.

Please no, no... http://www.typescriptlang.org/  Why the hell would I want to code in another language to have it compiled into Javascript? *sigh*

Approaching the topic from a different angle, the corporate Twitter account for Neave Interactive, a London based UI development firm, questions whether learning JavaScript is difficult enough to warrant its replacement or abstraction via compile-to-JavaScript alternatives.

Is JavaScript really that scary? CoffeeScript, Dart, and now TypeScript typescriptlang.org @TypeScriptLang” increase

While all of its proponents, detractors, and competitors are voicing their opinions, it cannot be disputed that TypeScript has entered an increasingly popular area of software development. JavaScript is now being considered as a viable solution for not only front-end web experience, but also for creating desktop applications, and reliable server-side products as well. Mark Johnson, an author for OSS Watch, notes how this swell of opportunity for JavaScript will likely reinforce the need for more JavaScript developers and as this need rises, the adoption of languages such as TypeScript and Dart will grow accordingly.

With the plethora of tools for writing cross-platform games and apps with JavaScript, as well as platforms such as Windows 8 and Open WebOS bringing web technologies to the desktop, demand for the features offered by TypeScript is only going to increase.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Just program in Assembly language instead of compiling down by Dan Tines

...or to all the naysayers, if COBOL was the language of the browser, would they be saying just learn and improve COBOL?

Community questions by Jonathan Turner

Thanks for the article. Good to see the wide range.

One minor nit: "TypeScript" is mis-spelled "TyepScript" in the title.

Re: Just program in Assembly language instead of compiling down by Paulo Pinto

The problem is that you're left alone debugging assembly when something breaks down, trying to understand how the hell it maps to the original language.

Which in the end makes any sane developer rather improve his/her assembly skills than loosing time with the compiler of the month flavour.

Re: Just program in Assembly language instead of compiling down by James Strachan

TypeScript has support for Source Maps so you can debug it natively in Chrome just fine.

Its not just a compiler-flavour-of-the-month if it gives you much greater tooling support when editing the source code in an IDE. Though until IntelliJ supports TypeScript, only windows users will benefit from the nicer IDE tooling :(

Re: Just program in Assembly language instead of compiling down by Paulo Pinto

Yeah and source maps are again another thing that only Chrome supports properly.

Now back being productive with Assembly.

Re: Just program in Assembly language instead of compiling down by James Strachan

For browsers that don't yet support Source Maps, the generated JavaScript code is pretty clean and easy to debug - try it out.

The whole point of TypeScript is its based on JavaScript; it just adds optional typing, classes & modules - so the generated JavaScript isn't really much different to the source.

But hey, if you don't wanna use it, don't - noone's forcing you :)

Re: Just program in Assembly language instead of compiling down by Russell Leggett

For browsers that don't yet support Source Maps, the generated JavaScript code is pretty clean and easy to debug - try it out.

The whole point of TypeScript is its based on JavaScript; it just adds optional typing, classes & modules - so the generated JavaScript isn't really much different to the source.


Yes, and I think that's of key importance. This is much less a compilation to assembly as it is a superset where *most* of the features being added will *also be added to javascript in the next version* combined with optional type annotations. Anyone who knows TypeScript should also know JavaScript, and anyone serious about JavaScript should be thinking about getting familiar with the additions coming into ES6 - TypeScript just lets you play with them early.

To make a better analogy, looking at the output of TypeScript is not like looking at assembly out put from another language, its more like looking at the output of the Less CSS compiler. Less is a superset of CSS with some extra features. It shouldn't be a big deal to look at the output.

Wrong issue by Mark N

The problem with what Nicholas C. Zakas says about spending time learning JS is that the issue is NOT learning it. It is DEALING with it. I want to spend my time solving business problems not looking up how to us an JS API and then trying to figure out why the examples are wrong (or wrong for my situation).

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

8 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT