A while ago, I did a comparison of coffeescript and javascript https://blog.darkoverlordofdata.com/2014/03/coffeescript-vs-typescript.html. At the time, I felt that coffeescript was the better of the two. But typescript has seen some improvements, so it's time to compare them again.
Coffeescript
The main syntax difference is still there - whitespace vs curly brace. I like white space. My code editors don't. I have to be careful when I cut and paste coffeescript - make sure beutification is turned off, because if my white space is changed, so is my program logic.
Implicit returns - this is where the function automatically returns the value of the last assignment statment - have caused countless bugs. I think most of the community would like to see this changed, but it likely will never happen. I now have a habit of typing the return statement first, and the going back to fill in the body of the procedure.
Very little changes in coffeescript. Support has been added to the new es6 yield. The compile switch --join has been removed, which required a re-write of my build process.
Typescript
Typescript now has many of the features I was looking for and finding in coffeescript, plus more.
We now have string interpolation, generics, and annotaions.
You can now use an expression as a superclass.
Lambda's are supported with fat arrow binding to 'this'.
My code editors love typescript. Good code completion and auto braces make it just as easy to type as coffeescript. All in all, I find much better tooling is available for typescript.
If it sounds like all my new code is in typescript, you'd be half correct. For complex client side applications, I like typescript. For server side and command line programs, I still like coffeescript, and use it instead of bash for creating my build scripts.
Typescripts real strength is it's community involvement. Many of the pluses for typescript are comunity driven, and this is the real reason I've been using it more. The lack of community involvment with coffescript is probably it's worst feature, and the main reason I started looking at typescript.
No comments:
Post a Comment