Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Our first sip of CoffeeScript

Our first sip of CoffeeScript

CoffeScript quick talk!

RDstation (http://rdstation.com.br) is growing and we need Javscript more than ever.
At ResultadosDigitais we do internal talks to share knowledge, changes on our coding style, architecture, and impacting choices in general.

http://resultadosdigitais.com.br/trabalhe-conosco/

Lucas Neves Martins

August 21, 2013
Tweet

More Decks by Lucas Neves Martins

Other Decks in Programming

Transcript

  1. What it does for you Easier to read Easier to

    write OO code Better performance Less verbose Auto-scoping Identation is information
  2. The basics name = “RDstation” valid = true if valid

    console.log name var name, valid; name = “RDstation”; valid = true; if (valid){ console.log(name); }
  3. The basics: Callbacks $(‘#cool_button’).click(function(event){ console.log(‘do stuff with’+event); }); $(‘#cool_button’).click (event)

    -> console.log(“do stuff with #{event}”) $(‘#cool_button’).click -> console.log(‘do stuff’)
  4. The basics: Scoping out_of_scope = “Can’t touch this!” $(‘#cool_button’).click (event)

    -> console.log(“do stuff with #{event}”) console.log(out_of_scope) # undefined! out_of_scope = “Yes we can!” $(‘#cool_button’).click (event) => console.log(“do stuff with #{event}”) console.log(out_of_scope) # ha!
  5. The basics: Iterators list = [“One”, “Two”, “Three”, “Four”] for

    number in list console.log number hash = render: true, template: “moustache” for option,value in hash console.log “#{option} is #{value}”
  6. The basics: Operators is isnt not and or true, yes,

    on false, no, off @, this of in === !== ! && || true false this in Coffeescript Javascript
  7. Classes class Gemstone constructor: (@name) -> shine: -> console.log “#{@name}

    :sparkles:” ruby = new Gemstone “Ruby” ruby.shine() >> “Ruby :sparkles:”