Software often requires two or three iterations before you get it right. In our case this led to starting a rewrite of our hybrid mobile application. It had been developed over several years by a diverse group of people with varying coding practices, and it was deemed easier to rewrite it than to refactor it into a maintainable state.
Below is the results of our comparison between the three. This is not an extensive functional evaluation (a luxury not available for startups), but instead based primarily on reading the following books:
- The Little Book on CoffeeScript, by Alex MacCaw
- TypeScript Revealed, by Dan Maharry
- Dart: Up and Running, by Kathy Walrath & Seth Ladd
I can recommend these as good introductions to each language, as each one can be read in a few hours. You may also be interested in Anton Ivanov’s blog post comparing the three with code examples.
CoffeeScript – a fresh coat of paint
$(document).ready -> $.get '/', (data) -> $('body').append "Successfully got the page."
The language has many other influences from scripting languages like Python, Perl and Ruby, such as post-conditionals, operator aliases and string interpolation to name a few. It heavily promotes brevity of code, with the risk of it becoming cryptic to non-experts.
Update: After using CoffeeScript for six months, I’ve written a post on CoffeeScript woes, which highlights some pitfalls we’ve run into.
The primary new language features provided are (optional) static typing and a class framework. The type system allows catching a wide variety of problems during compile time, instead of runtime. The class and module framework allows easier modularization and writing of complex applications.
Microsoft has also developed comprehensive IDE support for TypeScript for Visual Studio. The static typing allows it to perform many advanced refactoring operations, such as global renaming, reference searching and code completion, enough to make any scripting language developer envious.
Dart – a fresh look at the web
The Dart language is not specifically designed for a browser, but more as a general usage language. Browser-specific functions, such as DOM manipulation, don’t rely on magic global variables, but are provided as libraries. The language resembles Java in many ways, and most programmers should be comfortable with it in a a day or two.
Which one to choose?
So, which one is the best? As always, that depends.
If we were using Microsoft tools for development, TypeScript would be a very tempting choice. As it is, we’re doing the majority of our development on Linux and Macs using Eclipse. A major part of the benefit of TypeScript comes from the tooling within Visual Studio. As support is developed for more IDEs this may change – for example WebStorm 6 from JetBrain already includes TypeScript support.
If I was starting a new desktop web app, I would definitely consider Dart. It’s a very clean, modern language with extensive libraries out-of-the-box. However, our application must also run on rather old mobile browsers, and interface properly with our native code. If we later find out that Dart code doesn’t run properly or fast enough on some devices, we may be at a dead end. This is a risk we didn’t want to take.
An added benefit is that CoffeeScript is probably the most widely adopted altJS language, and there’s a considerable amount of manuals and explanations for it, and more developers in the community to answer questions. Without any clear numbers, Google Trends provides some idea on the relative interest in each language.
Update 2: This trend has changed during 2015, with TypeScript clearly overtaking CoffeeScript in search popularity.
Which language have you chosen for your projects?
Checkout IcedCoffeeScript. Now that we’ve got sourcemaps (and Webstorm) If you’re going to go CoffeeScript you might as well got Iced
I quickly checked Iced a while back. We’re already using promises for all asynchronous control, and I think those provide a bit more flexibility than await/defer, though not necessarily quite as simple syntax. Still worth a look for everyone considering CoffeeScript.
webstorm doesn’t support IcedCoffeeScript
There’s also LiveScript http://livescript.net/ which is kind of a-little-bit-better CoffeeScript. — The problem with LiveScript is, I think, that all IDEs and toolkits focus on supporting CoffeeScript; no one cares about LIveScript because it’s a fairly new language, and while LiveScript is better than CoffeeScript, it doesn’t offer *that* many improvements (I think). — I’m using LiveScript by the way, but I’m thinking about porting to Dart, some years into the future.
Here’s the trend graph with LiveScript included:
LiveScript is amazing, yet there’s no types and it’s not supported well by major editors
Coming from a Python background, I’ve been very happy with RapydScript (https://github.com/atsepkov/RapydScript).
My primary language is python, so Coffeescript is godsend to me as an alternative to js.
Dart is unexciting and boring syntax wise, but it’s a good project and I wish it luck. Besides, we can always create a CoffeeScript for Dart 😉
An unexciting and boring syntax might not be appealing to coding gurus, but may be easier to scale to 100s of developers when you’re forced to hire mediocre talents as well.
You can also check out:
– Script# (https://github.com/nikhilk/scriptsharp)
– ClojureScript (https://github.com/clojure/clojurescript)
First is an excellent practical option for .Net developers (There are multiple successful projects using it). It does not require learning new language because it is mostly good-old c# 2.0. Btw it is mature, actively developed and has nice integration with popular JS libraries.
Second is mostly for Clojure fans. Strong side is that it is LISP! And the weak side is that there is rather bid difference between original code and generated JS.
VS IDE is not by any means the only, or even always the best way to develop with Typescript: Typescript support in Jetbrains’ Webstorm is excellent using nodejs Typescript plugin, pretty much matching VS IDE without pulling in a lot of IIS/C# crap into your projects. It’s also available for MAc, Linux and Windows:
Pingback: CoffeeScript woes | Code for Hire
Web programming sucks.
I was very excited about Dart in my first two days of learning,but now It feels like it is an
1. Ornitorrinco ,a very strange animal that tries to introduce OOP for the browser programming ,but only if you want to be a serious programmer,.
2. But Thre are two thing in Dart that make me really sad
3. 1-In Dart everything is an object,even primitives,so You have to pass everything by reference,this not only makes the things very verbose(you have to create an object named StringBuffer in order to get its value property and then assign to a new variable,thats madness)
4. see this video http://www.youtube.com/watch?v=DWtvhdJkiRE
And last but the most weird thing, Ithink Dart is the only language in our galaxy that does not have an operand ,in order to concatanate strings,they say this way the VM can infer that only numeric fileds are use with +,So why not using another operator like LUA does ?
Phyton and Coffescript base their flow in identation,so I didnt even take than seriously,There are many phyton programmers who types //Enddo as a comment in order to mimic something “that other languages have” and to make sure they can rearrange the program if “something goes wrong with the file”.
Programming for anything that has to run in a Browser is very verbose ,because You have to find the component you want like this (from Sencha Forum)
Why all “modern languages and frameworks” make me do it by myself,In Intraweb(a Library that generates code based in what you write in object Pascal,a kind of layer of abstraction) I didn t even know that the Dom existed,if The component was created all Ihad to do is write code like:
instead of Ext.getCmp(‘lblAddress’).color:=clred;
It´s been 10 days since I started learning Dart.
First,If someone says that every .NET and Java developer can get dart in 2 days they´re telling no more than lies.
The fact that DART was note made with a Class centric privacy model,makes it harder to someone like me that came from Object Pascal World.
The code style borrowed from Python also bothers me,It seems like magic,something I´ll have to get used to.
For me DART is really an ornitorrico,not because its uglier than a Completely OOP based language,but also because their creators have adapted it to the environment they want DART to live .
I Really miss my protected,overload,override and all this stuff,but I´m at the very beggining,maybe in some days I will be eating my words.
I also recommend looking into promises, which essentially provide a try/catch/finally framework for asynchronous programming. (Dart seems to have Future for similar functionality.)
Ok,I´m not very used to assyncronous programming ,so I´ll give closures and promisses a chance.
I´m also getting used to some concepts of DART,like passing everything by reference,although I really have to write more ,I realized that the vas majority of times I don´t change what I used to pass by value,and sometimes It can even increase readibility.
The market is getting a wrong idea about Dart.
I really have a feel that the market has a wrong idea about DART.
I think is a big lie from google that someone with experience in Java,C#,Delphi will get DART in two days, it does not work this way.
You probably have that feeling of “Why did they do it this way instead of doing it like C#”, but in the end you´ll see that you can do everything but having the advantage of having the power of RIA and Saas applications, architectures that not only appeal for the eyes of end users but are also easy to maintain and deploy.
Unfortunately not everything are flowers, although Dart has wonderful tools like the Dart Editor, it does not have a complete EcoSystem,it does not have a Jquery, EXTjS and so on, not now, but I think in at most one year the Polymer project will be ready and we´´ll be able to do this kind of applications but without Bugs and laziness.
Resuming,It think Dart is not the language of yesterday and today,It is the language of the next 30 years.
Choosing a technology because you want that some older browser run your application is just the evil itself.
That’s the unfortunate reality. A few years back we were all cursing IE6, now it’s IE9 / WP7 and Android 2.3…
We had already decided to do a complete rewrite of the code (which, in hindsight, was the correct course of action). So we didn’t have any legacy code we’d need to support.
When we made the decision, TypeScript support for other than Visual Studio was very new and the language itself had been public only a bit over half a year. We also liked some of the syntactic styles of CoffeeScript (especially the -> operator, which can greatly reduce boilerplate code and enhance readability).
TypeScript would probably have been a fine choice as well, perchance even better. But CoffeeScript seemed a safer option at the time, and we’ve been quite happy with it.
Thanks for this report. I quickly looked at those, and finally my conclusion is that it is almost harmless to use typescript. So it should be the right choice IMHO.
Your Google trends graph ends at 2013. Graph for last year tells a different story http://www.google.com/trends/explore#cat=0-5-31&q=coffeescript%2C%20typescript%2C%20dart&date=today%2012-m&cmpt=q&tz=Etc%2FGMT-3
That’s very true. I added an update noting this change in trends.
Checkout Transcrypt: Python 3.5 syntax, multiple inheritance, lean and fast code, multilevel sourcemaps http://www.transcrypt.org
Pingback: Coffeescript vs — Алкогольные напитки
хостинг картинок для сайта – хостинг картинок анимированный gif, хостинг картинок jpg