CoffeeScriptJavaScript in a simple way    Open Tech Talk – 22 Jan 2011         @HackerSpacePP           @lchanmann
CoffeeScript●    One-to-one with JavaScript●    Better functional syntax●    Compiles to the good parts
Why CoffeeScript?●    Less code●    Readability●    Easy to understand, and maintain●    But … you should know how JavaScr...
JavaScript
CoffeeScript
JavaScript
Coffee
JavaScript
CoffeeScript
Functionssquare = (x) -> x * xarea = (x, y) -> x * ycube = (x) -> x * square x
Objects                        kids = {                           brother: {kids =                              name: "Max...
Lexical Scoping / Variable Safety                        (function() {                          var change, inner, outer; ...
Splats...gold = silver = rest = "unknown"awardMedals = (first, second, others...) ->  gold   = first  silver = second  res...
OOPclass Animal  constructor: (@name) -> move: (meters) ->   alert @name + " moved " + meters + "m."class Snake extends An...
The Rest...✔   Existential operator✔   Pattern matching with object literals✔   Switch/When/Else✔   Chained comparison✔   ...
Last but not lease●    http://ryan.mcgeary.org/talks/2010/10/21/coffeescript-novarug/●    http://www.slideshare.net/mtaber...
Lim Chanmannhttp://chanmannlim.wordpress.com/           @lchanmann      chanmannlim@gmail.com           InSTEDD
Upcoming SlideShare
Loading in...5
×

CoffeeScript - JavaScript in a simple way

2,808

Published on

Published in: Technology
0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,808
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
86
Comments
0
Likes
10
Embeds 0
No embeds

No notes for slide

CoffeeScript - JavaScript in a simple way

  1. 1. CoffeeScriptJavaScript in a simple way Open Tech Talk – 22 Jan 2011 @HackerSpacePP @lchanmann
  2. 2. CoffeeScript● One-to-one with JavaScript● Better functional syntax● Compiles to the good parts
  3. 3. Why CoffeeScript?● Less code● Readability● Easy to understand, and maintain● But … you should know how JavaScripts concept work
  4. 4. JavaScript
  5. 5. CoffeeScript
  6. 6. JavaScript
  7. 7. Coffee
  8. 8. JavaScript
  9. 9. CoffeeScript
  10. 10. Functionssquare = (x) -> x * xarea = (x, y) -> x * ycube = (x) -> x * square x
  11. 11. Objects kids = { brother: {kids = name: "Max", brother: >> age: 11 name: "Max" }, age: 11 sister: { sister: name: "Ida", name: "Ida" age: 9 age: 9 } };
  12. 12. Lexical Scoping / Variable Safety (function() { var change, inner, outer; outer = 1;outer = 1 >> change = function() {change = -> var inner; inner = -1 inner = -1; outer = 10 return (outer = 10);inner = change() }; inner = change(); }).call(this);
  13. 13. Splats...gold = silver = rest = "unknown"awardMedals = (first, second, others...) -> gold = first silver = second rest = others
  14. 14. OOPclass Animal constructor: (@name) -> move: (meters) -> alert @name + " moved " + meters + "m."class Snake extends Animal move: -> alert "Slithering..." super 5sam = new Snake "Sammy the Python"sam.move()
  15. 15. The Rest...✔ Existential operator✔ Pattern matching with object literals✔ Switch/When/Else✔ Chained comparison✔ Array comprehension✔ Array slicing and splicing with ranges✔ Everything is an expression; always a return value✔ Function binding syntactical sugar✔ String and RegExp Interpolation✔ Multiline Strings, Heredocs, and Block Comments✔ "text/coffeescript" script tags with extras/coffee-script.js✔ Its just JavaScript
  16. 16. Last but not lease● http://ryan.mcgeary.org/talks/2010/10/21/coffeescript-novarug/● http://www.slideshare.net/mtaberski/coffee-script-6089214● http://jashkenas.github.com/coffee-script/
  17. 17. Lim Chanmannhttp://chanmannlim.wordpress.com/ @lchanmann chanmannlim@gmail.com InSTEDD
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×