Give me a REST, I just want to get my Message across Multi-cloud; Preparing yourself
Apr 01

CoffeeScript, Whitespace, and Coffee

JavaScript, Tech Add comments

I enjoy learning new languages. I am not on the yearly diet as the Pragmatic folks would desire, but when I can…. I enjoy expanding my mind as I have definitely experienced the fact that learning a new language makes me program differently in all of my other languages.

Clojure and Scala are interesting to me in the land of Java, but that isn’t where I have been spending time (until recently). I have been very much enjoying Jeremy Ashkenas’s CoffeeScript. What’s not to like? Jeremy has managed to create a language that cleans up many of the issues in JavaScript, and codifies much of the Good Parts into source form. Ruby is my favorite language, and this gets really close to my ideal mental model.

When talking to Brendan Eich about the language, he very much appreciates it, and also the fact that it maps nicely to the JavaScript model (versus something like GWT and Java mapping on top of JavaScript say).

In some ways it feels bizarre to write in a high level language which gets converted to another high level language. One thing that has been enjoyable though is learning this language. The killer features for me are:

  • Jeremy takes care of things like documentation. The main site is the best introduction and documentation for any language.
  • Source code as byte code. I don’t enjoy reading byte code. I do enjoy reading JavaScript code (a language I know well) though. It is fantastic to be able to play with a new language and instantly be able to see the JavaScript output, whether it be small things via the inline site, or via -w / cake watch.

Try CoffeeScript

One feature that I am not a huge fan of is the pythonic importance on significant whitespace. Notice the image above, and how the ordering of elements made a difference to the output.

It is very cool that Firefox is going to “natively” support loading up CoffeeScript, and I think that someone needs to create Coffee and do to Java what CoffeeScript has done to JavaScript.

You could argue that this has already been done….. Groovy? Oh and thanks to the great work of Charles, Tom, Ola, and friends…. I can even use JRuby over there…..

2 Responses to “CoffeeScript, Whitespace, and Coffee”

  1. James Strachan Says:

    BTW here’s an experimental fork of CoffeeScript that adds optional type annotations…

    https://github.com/jstrachan/coffee-script/blob/master/TypeAnnotations.md

    which can do nothing on the client side but could be used to generate very efficient static bytecode on the server side if your Coffee is mixed with Java / Scala / Groovy stuff.

  2. Elaine Says:

    I keep waiting for code that will remove all the useless code that auto-coding tools put in.
    Years ago I watched people coding C++ by hand. Those days are gone forever, except for a few old-timers. Today, software tools output the code, and no one knows exactly what most of it looks like, or much cares.
    There’s a ton of bloat in machine-generated code these days.

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: What are the first four letters in the word British?