Upload
dimitris-tsironis
View
1.794
Download
0
Embed Size (px)
DESCRIPTION
This is an intro presentation to the new and awesome language, Coffeescript. See the presentation for more details.
Citation preview
CoffeeScriptUnfancy JavaScript
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
Jeremy AshkenasInteractive News at the NYTimes / DocumentCloud • Creator of CoffeeScript + Backbone.js • Code is Literature
CoffeeScript is a little languagethat compiles into Javascript
It’s just Javascript!
Code is poetry...
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
Let’s see some code!
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)
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}”
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}”
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}”
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
You get the idea
hubot, make me some coffee please!
Hubot is your company's robot.Install him in your company to dramatically
improve and reduce employee efficiency.
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!
Written in CoffeeScript(and some Perl and Shell)
we have our own hubot
Meet Geembot!
Open source & expandable(original written by Github Inc.)
Thanks!
Follow me
@geembohq
@tsironakos