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

CoffeeScript

 CoffeeScript

Presented at the Exotic Programming Languages and the Web event hosted by Gilt Tech. http://tech.gilt.com

63e2f6b0de6ae817af2e185b82aa05c2?s=128

Mark Wunsch

October 20, 2011
Tweet

Transcript

  1. { } } { { { } } } }{

    { { }{ } } _____ __ __ ( }{ }{ { ) / ____| / _|/ _| .- { { } { }} -. | | ___ | |_| |_ ___ ___ ( ( } { } { } } ) | | / _ \| _| _/ _ \/ _ \ |`-..________ ..-'| | |___| (_) | | | || __/ __/ | | \_____\___/|_| |_| \___|\___| | ;--. | (__ \ _____ _ _ | | ) ) / ____| (_) | | | |/ / | (___ ___ _ __ _ _ __ | |_ | ( / \___ \ / __| '__| | '_ \| __| | |/ ____) | (__| | | | |_) | |_ | | |_____/ \___|_| |_| .__/ \__| `-.._________..-' | | |_| Wednesday, October 19, 11
  2. Mark Wunsch @markwunsch { } } { { { }

    } } }{ { { }{ } } _____ __ __ ( }{ }{ { ) / ____| / _|/ _| .- { { } { }} -. | | ___ | |_| |_ ___ ___ ( ( } { } { } } ) | | / _ \| _| _/ _ \/ _ \ |`-..________ ..-'| | |___| (_) | | | || __/ __/ | | \_____\___/|_| |_| \___|\___| | ;--. | (__ \ _____ _ _ | | ) ) / ____| (_) | | | |/ / | (___ ___ _ __ _ _ __ | |_ | ( / \___ \ / __| '__| | '_ \| __| | |/ ____) | (__| | | | |_) | |_ | | |_____/ \___|_| |_| .__/ \__| `-.._________..-' | | |_| Exotic Programming Languages and the Web .oooooo. ooooo ooooo ooooooooooooo d8P' `Y8b `888' `888' 8' 888 `8 888 888 888 888 888 888 888 888 888 ooooo 888 888 888 `88. .88' 888 888 o 888 `Y8bood8P' o888o o888ooood8 o888o Wednesday, October 19, 11
  3. var pg = require('pg'); //or native libpq bindings //var pg

    = require('pg').native var conString = "tcp://postgres:1234@localhost/postgres"; // error handling omitted pg.connect(conString, function(err, client) { client.query("SELECT NOW() as when", function(err, result) { console.log("Row count: %d",result.rows.length); // 1 console.log("Current year: %d", result.rows[0].when.getYear()); }); }); Wednesday, October 19, 11
  4. Wednesday, October 19, 11

  5. • compiles into JavaScript • JavaScript’s object model • “the

    good parts” • “It’s just JavaScript.” Wednesday, October 19, 11
  6. skus = (sku for id, sku of order.skus) fling =

    (img) -> $('body').append img img.show() img.css '-webkit-transform': "rotate(#{rando()}deg)" 'top': root.parseInt(img.css('top'), 10) - rando 45 'left': root.parseInt(img.css('left'), 10) - rando 45 'opacity': 0 root.setTimeout (-> img.hide().remove()), 5000 rando = (multiplier = 10) -> num = Math.ceil Math.random() * multiplier if num % 2 then -num else num Wednesday, October 19, 11
  7. skus = (sku for id, sku of order.skus) fling =

    (img) -> $('body').append img img.show() img.css '-webkit-transform': "rotate(#{rando()}deg)" 'top': root.parseInt(img.css('top'), 10) - rando 45 'left': root.parseInt(img.css('left'), 10) - rando 45 'opacity': 0 root.setTimeout (-> img.hide().remove()), 5000 rando = (multiplier = 10) -> num = Math.ceil Math.random() * multiplier if num % 2 then -num else num Wednesday, October 19, 11
  8. skus = (sku for id, sku of order.skus) fling =

    (img) -> $('body').append img img.show() img.css '-webkit-transform': "rotate(#{rando()}deg)" 'top': root.parseInt(img.css('top'), 10) - rando 45 'left': root.parseInt(img.css('left'), 10) - rando 45 'opacity': 0 root.setTimeout (-> img.hide().remove()), 5000 rando = (multiplier = 10) -> num = Math.ceil Math.random() * multiplier if num % 2 then -num else num Wednesday, October 19, 11
  9. skus = (sku for id, sku of order.skus) fling =

    (img) -> $('body').append img img.show() img.css '-webkit-transform': "rotate(#{rando()}deg)" 'top': root.parseInt(img.css('top'), 10) - rando 45 'left': root.parseInt(img.css('left'), 10) - rando 45 'opacity': 0 root.setTimeout (-> img.hide().remove()), 5000 rando = (multiplier = 10) -> num = Math.ceil Math.random() * multiplier if num % 2 then -num else num Wednesday, October 19, 11
  10. name = person.name {name} = person {name, age} = person

    tag = "<impossible>" [open, contents..., close] = tag.split("") if pin.properties.count isnt 1 for order, index in pin.properties.orders when (Date.now() - » Date.parse order?.submission_date) > (config.expiration ? 180000) class Mob constructor: (@name) -> move: (meters) -> alert @name + " moved #{meters}m." Wednesday, October 19, 11
  11. name = person.name {name} = person {name, age} = person

    tag = "<impossible>" [open, contents..., close] = tag.split("") if pin.properties.count isnt 1 for order, index in pin.properties.orders when (Date.now() - » Date.parse order?.submission_date) > (config.expiration ? 180000) class Mob constructor: (@name) -> move: (meters) -> alert @name + " moved #{meters}m." Wednesday, October 19, 11
  12. name = person.name {name} = person {name, age} = person

    tag = "<impossible>" [open, contents..., close] = tag.split("") if pin.properties.count isnt 1 for order, index in pin.properties.orders when (Date.now() - » Date.parse order?.submission_date) > (config.expiration ? 180000) class Mob constructor: (@name) -> move: (meters) -> alert @name + " moved #{meters}m." Wednesday, October 19, 11
  13. name = person.name {name} = person {name, age} = person

    tag = "<impossible>" [open, contents..., close] = tag.split("") if pin.properties.count isnt 1 for order, index in pin.properties.orders when (Date.now() - » Date.parse order?.submission_date) > (config.expiration ? 180000) class Mob constructor: (@name) -> move: (meters) -> alert @name + " moved #{meters}m." Wednesday, October 19, 11
  14. Common concerns Wednesday, October 19, 11

  15. Common concerns But what about my debugger? Wednesday, October 19,

    11
  16. Common concerns But what about my debugger? Compiled? Wednesday, October

    19, 11
  17. Thanks. Here are some links Mark Wunsch @markwunsch • http://coffeescript.org

    • https://github.com/jashkenas/coffee-script/wiki/List-of- languages-that-compile-to-JS • Line Number Mapping: https://github.com/jashkenas/coffee-script/ issues/558 • Hello World in Dart: https://gist.github.com/1277224 • Smooth CoffeeScript: http://autotelicum.github.com/Smooth- CoffeeScript/ • The Little Book on CoffeeScript: http://arcturo.github.com/ library/coffeescript/ Wednesday, October 19, 11