Share
Embed
CoffeeScript
Presented at the Exotic Programming Languages and the Web event hosted by Gilt Tech. http://tech.gilt.com
Mark Wunsch
October 20, 2011
Transcript
17 slides
-
{ } } { { { } } } }{
{ { }{ } } _____ __ __ ( }{ }{ { ) / ____| / _|/ _| .- { { } { }} -. | | ___ | |_| |_ ___ ___ ( ( } { } { } } ) | | / _ \| _| _/ _ \/ _ \ |`-..________ ..-'| | |___| (_) | | | || __/ __/ | | \_____\___/|_| |_| \___|\___| | ;--. | (__ \ _____ _ _ | | ) ) / ____| (_) | | | |/ / | (___ ___ _ __ _ _ __ | |_ | ( / \___ \ / __| '__| | '_ \| __| | |/ ____) | (__| | | | |_) | |_ | | |_____/ \___|_| |_| .__/ \__| `-.._________..-' | | |_| Wednesday, October 19, 11 -
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 -
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 -
• compiles into JavaScript • JavaScript’s object model • “the
good parts” • “It’s just JavaScript.” Wednesday, October 19, 11 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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