Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and processing.py

Friday, 4 November 2011

coffeescript, it's about time I tried it out

Well I think Jeremy Ashkenas (Jashkenas) is a very bright chap, and he has invented this thing called coffescript that turns writing javascript from something you might hate to do (but might have to do, to feed the family) to something enjoyable/satisfying. As I'm a linux user I don't have access to textmate, which is the obvious choice for a mac user (there is SublimeText2 but that is still in development, and they still want you to pay for it!!!). I'm comfortable with JEdit so I chose that, I've even created a little commando script so I can compile/run scripts from the editor (a coffee.xml syntax highlight mode is available here).
Here is something distasteful in coffeescript that I created earlier:-

fred = "wanker"
fred is "wanker"
fred isnt "tosser"
This is compiled to this javascript:-
(function() {
  var fred;
  fred = "wanker";
  fred === "wanker";
  fred !== "tosser";
}).call(this);
Actually this script is obviously completely pointless, but makes more sense when each command is run consecutively in the REPL, which is great way of exploring coffeescript syntax (just like in python or ruby).
tux@monkstone:~$ coffee
coffee> fred = "wanker"
'wanker'
coffee> fred is "wanker"
true
coffee> fred isnt "tosser"
true
By the way you don't even have to install coffescript to try it out, try it here http://jashkenas.github.com/coffee-script/ Further coffee/javascripts can/do work just as well on the server side as the client side check out the examples in this free book. Look what I've just found, as I thought someone would have done it already combining coffeescript and processing.js, I will definitely be giving it a go.

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2