Coffeescript

1,301 views

Published on

I was cleaning up my files this morning, and found this short little intro talk I gave at Winnipeg.RB a few months back when rails 3.1 came out with CoffeeScript enabled by default.

It's a micro introduction to C

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,301
On SlideShare
0
From Embeds
0
Number of Embeds
218
Actions
Shares
0
Downloads
13
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Coffeescript

  1. 1. CoffeeScript Like JavaScript, but without the horrible.Sunday, 27 November, 11
  2. 2. Burke Libbey Me @burkelibbeySunday, 27 November, 11
  3. 3. The 5 Second PitchSunday, 27 November, 11
  4. 4. var foo = function() { JavaScript return "bar"; } CoffeeScript foo = -> "bar"Sunday, 27 November, 11
  5. 5. “Sold! What did I just buy?”Sunday, 27 November, 11
  6. 6. “CoffeeScript is a little language that compiles into JavaScript” – Jeremy Ashkenas, CoffeeScript authorSunday, 27 November, 11
  7. 7. foo = -> "bar" CoffeeScript Compiler (function() { var foo; foo = function() { return "bar"; }; }).call(this);Sunday, 27 November, 11
  8. 8. “What’s wrong with JavaScript?” Browser inconsistencies Terrible DOM API Redundant syntaxSunday, 27 November, 11
  9. 9. “What’s wrong with JavaScript?” Browser inconsistencies Terrible DOM API Redundant syntax Most of the issues people have with JavaScript boil down to these three points.Sunday, 27 November, 11
  10. 10. “What’s wrong with JavaScript?” Browser inconsistencies Terrible DOM API Redundant syntax jQuery does a fantastic job of shielding you from these two.Sunday, 27 November, 11
  11. 11. “What’s wrong with JavaScript?” Browser inconsistencies Terrible DOM API Redundant syntax CoffeeScript fixes this one.Sunday, 27 November, 11
  12. 12. So what’s wrong with the syntax? function(x) { return x * x; } For a functional language, having to write “function” and “return” everywhere is more than a little strange.Sunday, 27 November, 11
  13. 13. Anonymous Function Syntax JavaScript function(x) { return x * x; } Scheme (lambda (x) (* x x)) Erlang fun(X) -> X * X end. CoffeeScript (x) -> x * x Haskell x -> x * x Clojure #(* % %)Sunday, 27 November, 11
  14. 14. “I’m a masochist, and I like typing a lot. Give me another reason.”Sunday, 27 November, 11
  15. 15. Rails 3.1 includes CoffeeScript by default.Sunday, 27 November, 11
  16. 16. ...to the chagrin of hypocrites the world over.Sunday, 27 November, 11
  17. 17. Sunday, 27 November, 11
  18. 18. Fighting Rails is usually doomed to failure.Sunday, 27 November, 11
  19. 19. So just suck it up and learn CoffeeScript.Sunday, 27 November, 11
  20. 20. Without further ado: CoffeeScript Whirlwind tourSunday, 27 November, 11
  21. 21. three = -> 3 square = (x) -> x * x add = (x, y) x + ySunday, 27 November, 11
  22. 22. Default values! fill = (container, liquid = "coffee") -> "Filling the #{container} with #{liquid}..." ...and string interpolation!Sunday, 27 November, 11
  23. 23. YAML-like hash literals work kids = brother: name: "Max" age: 11 sister: name: "Ida" age: 9Sunday, 27 November, 11
  24. 24. Never type “var” again! CoffeeScript does it for you.Sunday, 27 November, 11
  25. 25. mood = greatlyImproved if singingSunday, 27 November, 11
  26. 26. if happy and knowsIt clapsHands() chaChaCha() else showIt()Sunday, 27 November, 11
  27. 27. date = if friday then sue else jillSunday, 27 November, 11
  28. 28. options or= defaultsSunday, 27 November, 11
  29. 29. I’m out of slides. Time for live-coding!Sunday, 27 November, 11
  30. 30. Thanks!Sunday, 27 November, 11

×