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

Dimitris Tsironis

December 07, 2012
Tweet

More Decks by Dimitris Tsironis

Other Decks in Technology

Transcript

  1. 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
  2. Jeremy Ashkenas Interactive News at the NYTimes / DocumentCloud •

    Creator of CoffeeScript + Backbone.js • Code is Literature
  3. 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
  4. 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)
  5. 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}”
  6. 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}”
  7. 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}”
  8. 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
  9. Hubot is your company's robot. Install him in your company

    to dramatically improve and reduce employee efficiency.
  10. 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!