Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Coffescript - take a sip of code

Coffescript - take a sip of code

This is an intro presentation to the new and awesome language, Coffeescript. See the presentation for more details.

Most of the content was taken from Codeschool's course

Ca017edd68f0d216c4761445bf9f28e7?s=128

Dimitris Tsironis

December 07, 2012
Tweet

Transcript

  1. CoffeeScript Unfancy JavaScript

  2. Dimitris Tsironis CEO & Founder at Geembo UI designer &

    huge geek, who loves good design and french fries, as much as good indentation in a stylesheet. @tsironakos
  3. Jeremy Ashkenas Interactive News at the NYTimes / DocumentCloud •

    Creator of CoffeeScript + Backbone.js • Code is Literature
  4. CoffeeScript is a little language that compiles into Javascript

  5. It’s just Javascript!

  6. Code is poetry...

  7. A beautiful programming language Least amount of code to get

    the job done Readable and understandable Easy to maintain well, should have elegant and beautiful form
  8. Let’s see some code!

  9. Variables var message; message = “Ready for some coffee?”; alert(message);

    CoffeeScript JavaScript coffee = -> confirm “Ready for some coffee?” Functions var coffee = function() { return confirm(“Ready for some coffee?”); } CoffeeScript JavaScript message = “Ready for some coffee?” alert(message)
  10. Example CoffeeScript var coffee; coffee = function() { var answer;

    answer = confirm(“Ready for some coffee?”); return “Your answer is ” + answer; } JavaScript coffee = -> answer = confirm “Ready for some coffee?” “Your answer is ” + answer or “Your answer is #{answer}”
  11. Function Parameters CoffeeScript var coffee; coffee = function(message) { var

    answer; answer = confirm(message); return “Your answer is “ + answer; } JavaScript coffee = (message) -> answer = confirm message “Your answer is #{answer}”
  12. Optional Parameters CoffeeScript var coffee; coffee = function(message) { var

    answer; if (message == null) { message = “Ready for some coffee?”; } answer = confirm(message); return “Your answer is “ + answer; } JavaScript coffee = (message = “Ready for some coffee”) -> answer = confirm message “Your answer is #{answer}”
  13. Applied jQuery CoffeeScript jQuery(function($) { function changeTab(e) { e.preventDefault();\ $(“#tabs

    li a.active”).removeClass(“active”); $(this).addClass(“active”); } $(“#tabs ul li a”).click(changeTab); }); jQuery $ -> changeTab = (e) -> e.preventDefault() $(“#tabs li a.active”).removeClass “active” $(@).addClass “active” $(“#tabs ul li a”).click changeTab
  14. You get the idea

  15. hubot, make me some coffee please!

  16. Hubot is your company's robot. Install him in your company

    to dramatically improve and reduce employee efficiency.
  17. What he/she does Lives in your chat (Campfire, GTalk, Hipchat

    etc.) Deploys your code Connect to your issues, commits etc. Finds funny cat gifs Integrates with almost every service on Earth Manages the playlist in your office everything you could imagine!
  18. Written in CoffeeScript (and some Perl and Shell)

  19. we have our own hubot Meet Geembot!

  20. Open source & expandable (original written by Github Inc.)

  21. Thanks! Follow me @geembohq @tsironakos