CoffeeScript vs TypeScript vs JavaScript - my thoughts

Throughout this post I’d like to share my thoughts on Coffee-, Type- and JavaScript, because a lot of people from the community were asking my for which language they should go or why I’ve chosen CoffeeScript for writing my SharePoint framework ShareCoffee. First of all, I’ve been doing JavaScript for a long, long time. I’ve spend a lot of time reading books on how to write JavaScript code and how to do it well. Here for example two (in my opinion essential) books for JavaScript Developers, independent from their skill.

  • JavaScript the good parts
  • Object-Oriented JavaScript

    With the release of CoffeeScript 0.1.0 back in 2009 I’ve started to play around with CoffeeScript. CoffeeScript is nothing more than JavaScript on steroids :) It’s a language which compiles into JavaScript (same is of course true for TypeScript). CoffeeScript goes one step further than plain old JavaScript, it adds a lot of great languages features known from Ruby (the sexiest programming language on earth). During compile-time the CoffeeCompiler is responsible for translating your CoffeeScript code into the good parts of JavaScript and this is the biggest advantage. It’s generating robust, secure and standardized JavaScript goal by paying attention to the golden CoffeeScript rule “It’s just JavaScript”. Since GA of CoffeeScript it became more and more popular and many frameworks and tools such as RubyOnRails or IDE’s like VisualStudio are adapting the language and giving programmers the chance to write their client side code in CoffeeScript instead of plain old JavaScript. For CoffeeScript there is also available a great book which I’ve read within almost 2 days. - CoffeeScript Application Development

    When talking about TypeScript, you should consider that TypeScript is – compared to CoffeeScript – really young. TypeScript is developed by Microsoft and its first release was back in 2012. Typescript is highly addicted to the (nobody can say exactly when) upcoming ECMA script standard. TypeScript offers also support for classes and inheritance as CoffeeScript does, but in addition to that TypeScript adds support for Types and Generics to the client side. The TypeScript syntax looks a little bit like C# and makes it easy for .NET developers to move from the server-side coding to the client-side. Microsoft is not only providing packages to write TypeScript on Windows, based on NodeJS you can also write and compile TypeScript from any platform supporting NodeJS. That’s awesome. Regarding the question “Which language should I use? TypeScript or CoffeeScript?” I can’t tell you the right answer. I always say something like “It depends on your team. Just give your team a rough introduction into both languages and give them the chance to write some spikes using both.” Depending on the results you should either go for CoffeeScript or TypeScript. But independent from this choice it’s absolutely important that you chose one of these. Writing plain old JavaScript is of course required somewhere.. But the biggest advantage of both languages are their compilers. Think about the compilers as an extra security gate preventing your client-side code from breaking a release-candidate. Hopefully I could give you a rough introduction and some good points why it’s important to move on and use the great languages available, instead of using plain old JavaScript.

Comments

comments powered by Disqus