Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.



Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this


  1. 1. CoffeeScript 2011.12.09
  2. 2. ( jump in anytime )
  3. 3. “Javascript is the assembly of the web”
  4. 4. A seed of truth.• Developer needs evolve, the language does not.• Some folks are tackling complexity with compilers. • Async, strong types, tier-less, language translators, etc.• Precedent: C++ originally compiled to C.• compile-to-JS
  5. 5. Personally, not a fan.• Too much distance between man and machine.• Too fringe.• Too useless.• Too risky.• Javascript is fine.
  6. 6. Until ...
  7. 7. CoffeeScript• By Jeremy Ashkenas (of underscore & backbone fame)• Released in 2009, now at version 1.1.3• Philosophy • “It’s just Javascript”. • Readable compiled code. • No runtime impact.
  8. 8. Language Overview.
  9. 9. Strengths.
  10. 10. Scoping• All compiled code executes in function scope.• All variables are declared in function scope.• Global variables must be explicitly added to the root context.• Strict lexical scope.
  11. 11. Elegant syntax• Significant whitespace.• Concise function declarations.• Concise literals.• Sane inheritance.• Beautiful to read and write.
  12. 12. Excised “Bad Parts”• Equality with type coercion.• The with and eval statements.• Trailing commas in object literals.• “Fall through” switch statements.
  13. 13. Lots of Sugar• Comprehensions, string interpolations, default arguments, multi-line strings, aliases for this and prototype, existential operator, immediate invocation, splats, array and object unpacking, fat arrow, chained comparisons, etc, etc.
  14. 14. Weaknesses.
  15. 15. Debug Compiled Code.• Table stakes.You need to know Javascript.• Not a problem in my experience. • Compile in your head. • Read the Javascript.• Debug line number mapping is coming ... someday, maybe?
  16. 16. Too cute sometimes?• Proliferation of boolean symbols and operators • true/false, yes/no, on/off • true == isnt false• Parenthesis invocation rules are inconsistent (but fine) • Reference: func • Invocation: func(), func(‘aa’), func ‘aa’
  17. 17. Things to watch out for.
  18. 18. Everything is an expression.• Everything is an expression, conditionals and loops included.• Functions return last statements by default.• Becareful to not return the value of loops/conditionals used for side effects. Might incur performance hit.• Ultimately, easy to remember.
  19. 19. Tools.
  20. 20. They work.• Javascript libraries work as normal.• Compile on the fly. • coffee --watch, sprockets, guard, etc.• Good editor support.
  21. 21. In the wild.• Still a fraction of the JS world.• Notable Users • Rails 3.1, Github, 37 Signals, Shopify• Bootstrapped compiler.• Popular in Node & the browser.• Plenty of repos, followers, watchers on Github.
  22. 22. So should you use it?
  23. 23. Obvious Risks.• Yet another language. • But it’s small, easy to learn and is still just Javascript.• Early adopter? • But syntax is quite stable, but things will change.• Flash in the pan? • Not likely but worst case, check in the Javascript.
  24. 24. Your choice.
  25. 25. At least understand it• You’ll face the same problems that motivated CoffeeScript.• CoffeeScript is influencing the direction of• And have some fun.
  26. 26. But I like it.
  27. 27. My CoffeeScript.•••
  28. 28. Resources• • Reference, books, tutorials, podcasts, etc.• #coffeescript on freenode• @coffeescript
  29. 29. Thoughts? Questions?