Coffee script throwdown


Published on

Node.pgh Meetup 0.13

Published in: Technology
1 Comment
1 Like
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Coffee script throwdown

  1. 1. Throw-downNode.pgh Meetup
  2. 2. Nicholas McClayUX Designer & Developer@nickmcclay
  3. 3. There are a lot of opinions about CoffeeScript
  4. 4. “You can take my JavaScript when you pry it from“You can take my JavaScript when you pry it from my cold dead hands!” my cold dead hands!”
  5. 5. Let’s take a deep breathand try and have an open mind here...
  6. 6. What is ? CoffeeScript is a small language that compiles into JavaScript Usable for client-side and server-side applications (Node.js) Has an opinionated alternative syntax for building JavaScript applications
  7. 7. What is a Trans-compiling Language? Language? Compile .coffee .js
  8. 8. Pick your problem“I want a better JavaScript!” “I want functional programming!” “I want strict typing!” Objective-J “I want Objective-C!” “I work at google!”
  9. 9. Why should I care about CoffeeScript?
  10. 10. Question: How many of you use CoffeeScript?
  11. 11. Question: How many ofyou have used a modulewritten in CoffeeScript?
  12. 12. Isaac Schleuter (maintainer of Node.js / NPM) Node’s top contributors TJ Holowaychuk (express, Jade, Mocha) No Mikeal Rogers (Request) No No James Haliday "substack" (Browserify, dnode, Optimist) No Guillermo Rauch (Socket.IO) No No Aaron Heckmann (Mongoose) No No Nathan Rajich "Too Tall Nate" (node-gyp) No Marak Squires (, pdf.js, color.js) No Felix Geisendörfer Tim Caswell (NVM)
  13. 13. And Yet...Larger Node Community Yes Currently ranked 4th as the most depended upon module in NPM More than Express! (just barely)
  14. 14. Getting Started with CoffeeScript
  15. 15. Learning CoffeeScript
  16. 16. Give it a try! Installsudo npm install -g coffee-script Start the CoffeeScript REPLcoffee Compile a .coffee file into equivalent .jscoffee --compile <path to js file>Compile .coffee file when source changescoffee --watch --compile <path to js file> Compile and start file with Node.jscoffee --nodejs <path to node.js file>
  17. 17. Basic Node Connect Server
  18. 18. CoffeeScript Principles 1 - Clarity 2 - Uniformity 3 - Ease of Translation to JavaScript
  19. 19. Clarity
  20. 20. Significant White Space 1/2 to 1/3 compared to pure JavaScript
  21. 21. Keywords
  22. 22. Default Arguments
  23. 23. ((Parentheticals) Optional)
  24. 24. Uniformity Everything is an expression!
  25. 25. Language Enhancements Array Comprehension, Classes, and much more...
  26. 26. Fix some JavaScript pitfalls this, null and undefined, prototype wackiness, goodbye default global!
  27. 27. Ease of Translation to Javascript The golden rule of CoffeeScript is: "Its just JavaScript" The compiled output is readable and pretty-printed, passes through JavaScript Lint without warnings
  28. 28. Learning Pains
  29. 29. CoffeeScript Misunderstandings CoffeeScript is NOT a superset of JavaScript CoffeeScript is compiled NOT interpreted at runtime You must SHOULD learn JavaScript before using CoffeeScript Compiled CoffeeScript CAN be slower than pure JavaScript, but really this usually isn’t an issue.
  30. 30. Mind the gap...
  31. 31. Mind the gap...
  32. 32. Punctuation Counts...
  33. 33. Punctuation Counts... OR
  34. 34. CoffeeScript Pain Points?Requires a compilation step (use file watcher or --watch)Community is a subset of larger JavaScript communityDebugging...
  35. 35. CoffeeScript Debugging Strategies
  36. 36. Mental Map Debugging “You wanted to write it in CoffeeScript, you figure it out.”
  37. 37. Source Map Debugging .js .map .coffee
  38. 38. WebStorm + CoffeeScript
  39. 39. Issue in WebStorm 6 CoffeeScript gives you : WebStorm wants : Manually adjusting the source map reference makes it work...
  40. 40. Even products that advertise CoffeeScript support can have issues...
  41. 41. Add “await” and “defer” keywords for async
  42. 42. Thanks!@nickmcclay