CoffeeScript in MotionBy Geoffrey Grosenbach
jQuery -> $('#entry').focus()
1. A simple function
Engineering + Creativity
In his book Rise of the Creative Class, Richard Florida defines a list of creative professions that includes graphic designers, sculptors, architects, and…software writers.
CoffeeScript invents some good ideas and steals many others. The number one source I could identify for the most useful ideas in CoffeeScript? Perl.
Yes, Perl. The language that’s guaranteed to produce an audible gasp if mentioned in civilized programming circles today. Yet for ten solid years, Perl was a petri dish of syntactic innovation. Extended regular expressions, destructuring assignment.
Which is why it’s exciting to see syntactic experimentation happening with such vigor in CoffeeScript.
2. Jasmine’s ‘describe’ function with args
3. The @ syntax for instance properties
beforeEach -> @dish = new Dish 'Steak $18.99'
“Everybody shows off
And wants to look presentable
But the fact of the matter
Is that accidents are preventable.” — Buck 65
4. An instance method
add: (dish) -> @dishes.push dish
5. A full class with constructor
class Money constructor: (rawString) -> @cents = @parseCents rawString
6. Object literal
toJSON: -> title: @title price: @price.toString()