SlideShare a Scribd company logo
1 of 30
COFFEESCRIPT
“It’s just JavaScript”
Me
• Zarar Siddiqi
• Agile Coach with a developer’s itch
• http://www.linkedin.com/in/zararsiddiqi
• zarar_siddiqi@epam.com
• Confluence page for This Week @:
• https://kb.epam.com/pages/viewpage.action?pageId=107875299
• Next week: Agile Games!
Agenda
• Why Bother?
• Basic Concept
• Simple But High ROI Features
• Other Nice Features
• Code Playground
• Windows Installation
• Examples
• Conclusion (or something like it)
• Discussion
WHY BOTHER?
1.1: LIBRARIES
#1: JavaScript Use Exploding
1.2: MVVM, SINGLE-PAGE APPS
1.3: MOBILE
1.4: SERVER
#2: Problems with JavaScript
• Ambiguous constructs leading to verbosity
• function, prototype, extend, var, (function() {});
• Error-prone with late visibility
• Trailing commas, string concatenation, context binding, equality
• Limited features
• List comprehension, string interpolation, conditional modifiers
• Namespace pollution
• All <script> files loaded in one global scope
• PHP Problems
• Easy to get started; easy to go downhill
The math is simple
Lots of
JS
Easy to
write
messy
JS
Lots of
messy
JS
BASIC CONCEPT
How it works
file.coffee Compile file.js
page.html
<script> tag
Analogous to less for CSS - http://lesscss.org/
Benefits
• .coffee has less code to maintain – 35-45% less
• Produces JSLint validated code (http://jslint.com)
• http://javascript.crockford.com/code.html
• Easy-to-read code (Influenced by Ruby, Python, Haskell)
• Focuses on JavaScript: The Good Parts (Douglas Crockford):
http://amzn.to/176RA4
• Written by smart people, very strong community support,
mature (3.5 years)
• Easy to unit test (Jasmine) - http://pivotal.github.io/jasmine/
SIMPLE BUT HIGH ROI
FEATURES
#1: Defining classes
- Some ways of defining objects in JavaScript:
- Using function
- Using prototype
- var obj = {}
Let’s look at some examples…
Here’s one way…
// Using a function
function Apple (country) {
this.country = country;
this.color = "red";
this.getInfo = getAppleInfo;
}
function getAppleInfo() {
return this.country + ' has ' +
this.color + 'apples'.;
}
Here’s another…
// Using the prototype
function Apple (country) {
this.country = country;
this.color = "red";
}
Apple.prototype.getInfo = function() {
return this.country + ' has '
+ this.color + 'apples'.;
};
This will work too…
// Using object literals
var apple = {
country: "Sweden",
color: "red",
getInfo: function () {
return this.country + ' has '
+ this.color + 'apples'.;
}
}
Equivalent CoffeeScript class
class Apple
constructor: (@country) ->
@color = "red"
getInfo: ->
"{@country} has {@color} apples"
class BakedApple extends Apple
constructor: ->
super(“Canada”)
@color = “brown”
// No method keyword
// @ instead of this
// Implicit assignment
// Indentation
// Sensible class
declaration
// Interpolation
// Implicit returns
// Easy inheritance model
#2: The var problem
Example 1
function foo() {
var name = “Bob”;
age = 29;
}
alert(name);
alert(age);
Example 2
function printTen() {
for (i=0; i<10; i++) {
console.log(i);
}
return true
}
printTen();
alert(i);
CoffeeScript default scope is local
CoffeeScript
foo: ->
name = "Bob"
age = 29
JavaScript
printTen: function() {
var i, _i;
for (i = _i = 0; _i <= 10; i = _i += 1) {
console.log(i);
}
return true;
}
printTen();
alert(i);
function foo() {
var age, name;
name = "Bob";
age = 29;
}
printTen: ->
for i in [0..10] by 1
console.log i
return true
printTen()
alert(i)
#3: Outer Scope Referencing
JavaScript
function User(name) {
this.name = name;
}
User.prototype.save = function() {
var _this = this;
$.post('/user/save', function(data){
$('.msg').html(_this.name+ "saved.");
});
};
CoffeeScript
class User
constructor: (@name) ->
save: ->
$.post '/user/save', (data) =>
$('.msg').html("#{@name} saved.")
#4: Object Literal Readability / Writability
CoffeeScript
config =
user:
id: 'jsmith'
name:
first: 'John'
last: 'Smith'
password: 'pass '
email: 'jsmith@example.com'
host: 'localhost'
port: 3306
conn: -> App.connect()
JavaScript
config = {
user: {
id: 'jsmith',
name: {
first: 'John',
last: 'Smith'
},
password: 'pass',
email: 'jsmith@example.com'
},
host: 'localhost',
port: 3306,
conn: function() {
return App.connect();
}
};
#5: Testing Equality
"" == "0" // false
0 == "" // true
0 == "0" // true
false == "false" // false
false == "0" // true
false == undefined // false
false == null // false
null == undefined // true
" trn" == 0 // true Type
Coercion!
Solution: Use the is and isnt keywords which compare
without coercing and are more readable:
if a is b
doSomething()
SYNTACTIC SUGAR
“make things easier to read or to express.”
A spoonful of sugar…
# Existence checking
if happy?
console.log "clap your hands"
# Skip null checks
truck.getTires()?.change()
# Tuple-like assignments
[a, b] = [1, 2]
if (truck.getTires() != null)
truck.getTires().change()
if (typeof happy !== "undefined"
&& happy !== null)
Some more sugar…
# Iterate over a list with index
for item, i in someList
alert “Item #{i} is #{item}“
# Conditional modifiers
# Conditional modifiers
turnOn() if buttonPressed is true
status = 'expired' unless withinRange()
A whole jar of sugar…
• http://coffeescript.org/
CODE PLAYGROUND
Installation
After downloading and installing NodeJS from
http://nodejs.org/download/
Execute following from command prompt:
C:>npm -g install coffee-script
C:>coffee
coffee>
FINALLY…
As with everything…
• Use the right tool for the right job
• If it’s a small piece of JS, don’t bother. If it’s a JS-heavy
project, consider it
• Philosophical Debate:
Highly disciplined developers following a style guide
vs.
A language that helps standardize the produced code
Resources
• CoffeeScript Home Page
• http://coffeescript.org/
• JS2Coffee (Coffee2JS)
• http://js2coffee.org/
• Should you learn CoffeeScript?
• http://net.tutsplus.com/articles/interviews/should-you-learn-
coffeescript/
• Google Search – CoffeeScript Sucks
• http://goo.gl/MNQrY
• Brendan Eich
• https://brendaneich.com/2011/05/my-jsconf-us-presentation/
• The Little Book on CoffeeScript
• http://arcturo.github.io/library/coffeescript/

More Related Content

What's hot

Concurrent PHP in the Etsy API
Concurrent PHP in the Etsy APIConcurrent PHP in the Etsy API
Concurrent PHP in the Etsy APIMatt Graham
 
EmberConf 2016 – Idiomatic Ember (Speaker Notes)
EmberConf 2016 – Idiomatic Ember (Speaker Notes)EmberConf 2016 – Idiomatic Ember (Speaker Notes)
EmberConf 2016 – Idiomatic Ember (Speaker Notes)Lauren Elizabeth Tan
 
Alexa in 10 minutes
Alexa in 10 minutesAlexa in 10 minutes
Alexa in 10 minutesJames Burt
 
Alexa Smart Home Skill
Alexa Smart Home SkillAlexa Smart Home Skill
Alexa Smart Home SkillJun Ichikawa
 
EmberConf 2016 – Idiomatic Ember: Finding the Sweet Spot of Performance & Pr...
 EmberConf 2016 – Idiomatic Ember: Finding the Sweet Spot of Performance & Pr... EmberConf 2016 – Idiomatic Ember: Finding the Sweet Spot of Performance & Pr...
EmberConf 2016 – Idiomatic Ember: Finding the Sweet Spot of Performance & Pr...Lauren Elizabeth Tan
 
Introduction to POP animation engine
Introduction to POP animation engineIntroduction to POP animation engine
Introduction to POP animation engineSubhransu Behera
 
Using BDD to Solve communication problems
Using BDD to Solve communication problemsUsing BDD to Solve communication problems
Using BDD to Solve communication problemsRodrigo Urubatan
 
Building Boston Rail - An Alexa Skill
Building Boston Rail - An Alexa SkillBuilding Boston Rail - An Alexa Skill
Building Boston Rail - An Alexa SkillCharles J Christina
 
Forget what you think you know: Redefining functional programming for Scala
Forget what you think you know: Redefining functional programming for ScalaForget what you think you know: Redefining functional programming for Scala
Forget what you think you know: Redefining functional programming for ScalaKelley Robinson
 

What's hot (12)

Concurrent PHP in the Etsy API
Concurrent PHP in the Etsy APIConcurrent PHP in the Etsy API
Concurrent PHP in the Etsy API
 
EmberConf 2016 – Idiomatic Ember (Speaker Notes)
EmberConf 2016 – Idiomatic Ember (Speaker Notes)EmberConf 2016 – Idiomatic Ember (Speaker Notes)
EmberConf 2016 – Idiomatic Ember (Speaker Notes)
 
Alexa in 10 minutes
Alexa in 10 minutesAlexa in 10 minutes
Alexa in 10 minutes
 
Babygeddon presentation
Babygeddon presentationBabygeddon presentation
Babygeddon presentation
 
Alexa Smart Home Skill
Alexa Smart Home SkillAlexa Smart Home Skill
Alexa Smart Home Skill
 
EmberConf 2016 – Idiomatic Ember: Finding the Sweet Spot of Performance & Pr...
 EmberConf 2016 – Idiomatic Ember: Finding the Sweet Spot of Performance & Pr... EmberConf 2016 – Idiomatic Ember: Finding the Sweet Spot of Performance & Pr...
EmberConf 2016 – Idiomatic Ember: Finding the Sweet Spot of Performance & Pr...
 
Introduction to POP animation engine
Introduction to POP animation engineIntroduction to POP animation engine
Introduction to POP animation engine
 
Using BDD to Solve communication problems
Using BDD to Solve communication problemsUsing BDD to Solve communication problems
Using BDD to Solve communication problems
 
Building Boston Rail - An Alexa Skill
Building Boston Rail - An Alexa SkillBuilding Boston Rail - An Alexa Skill
Building Boston Rail - An Alexa Skill
 
Demystifying Scala
Demystifying ScalaDemystifying Scala
Demystifying Scala
 
Forget what you think you know: Redefining functional programming for Scala
Forget what you think you know: Redefining functional programming for ScalaForget what you think you know: Redefining functional programming for Scala
Forget what you think you know: Redefining functional programming for Scala
 
Let's do SPA
Let's do SPALet's do SPA
Let's do SPA
 

Viewers also liked

CoffeeScript: The Good Parts
CoffeeScript: The Good PartsCoffeeScript: The Good Parts
CoffeeScript: The Good PartsC4Media
 
"Vendor Everything" still applies
"Vendor Everything" still applies"Vendor Everything" still applies
"Vendor Everything" still appliesRyan McGeary
 
One Man Lightning Talks
One Man Lightning TalksOne Man Lightning Talks
One Man Lightning TalksRyan McGeary
 
Chelsea Hayman
Chelsea HaymanChelsea Hayman
Chelsea Haymanhayma1ce
 
Życzenia Wielkanocne
Życzenia WielkanocneŻyczenia Wielkanocne
Życzenia WielkanocneCR1ST0V40
 
Unauthorized Biography of Trish
Unauthorized Biography of TrishUnauthorized Biography of Trish
Unauthorized Biography of Trishboylanp
 
Chelsea Hayman
Chelsea HaymanChelsea Hayman
Chelsea Haymanhayma1ce
 
ADHD_session_one
ADHD_session_oneADHD_session_one
ADHD_session_onecindyyew
 
SlideShare
SlideShareSlideShare
SlideSharehayma1ce
 
БиоИнвест Россия 2011. Государство. Наука. Бизнес. Инвестиции
БиоИнвест Россия 2011. Государство. Наука. Бизнес. ИнвестицииБиоИнвест Россия 2011. Государство. Наука. Бизнес. Инвестиции
БиоИнвест Россия 2011. Государство. Наука. Бизнес. Инвестицииmegavladon
 
BioInvest Russia-2011
BioInvest Russia-2011BioInvest Russia-2011
BioInvest Russia-2011megavladon
 
SlideShare
SlideShareSlideShare
SlideSharehayma1ce
 
Chelsea Hayman
Chelsea HaymanChelsea Hayman
Chelsea Haymanhayma1ce
 
Family gathering april 2011
Family gathering april 2011Family gathering april 2011
Family gathering april 2011Rony Lotan
 
Traction story map plan
Traction   story map planTraction   story map plan
Traction story map planNight Wolf
 
Slideshare
SlideshareSlideshare
Slidesharehayma1ce
 

Viewers also liked (20)

Coffeescript
CoffeescriptCoffeescript
Coffeescript
 
CoffeeScript: The Good Parts
CoffeeScript: The Good PartsCoffeeScript: The Good Parts
CoffeeScript: The Good Parts
 
"Vendor Everything" still applies
"Vendor Everything" still applies"Vendor Everything" still applies
"Vendor Everything" still applies
 
Why A Wiki?
Why A Wiki?Why A Wiki?
Why A Wiki?
 
One Man Lightning Talks
One Man Lightning TalksOne Man Lightning Talks
One Man Lightning Talks
 
CoffeeScript By Example
CoffeeScript By ExampleCoffeeScript By Example
CoffeeScript By Example
 
Ruby Internals
Ruby InternalsRuby Internals
Ruby Internals
 
Chelsea Hayman
Chelsea HaymanChelsea Hayman
Chelsea Hayman
 
Życzenia Wielkanocne
Życzenia WielkanocneŻyczenia Wielkanocne
Życzenia Wielkanocne
 
Unauthorized Biography of Trish
Unauthorized Biography of TrishUnauthorized Biography of Trish
Unauthorized Biography of Trish
 
Chelsea Hayman
Chelsea HaymanChelsea Hayman
Chelsea Hayman
 
ADHD_session_one
ADHD_session_oneADHD_session_one
ADHD_session_one
 
SlideShare
SlideShareSlideShare
SlideShare
 
БиоИнвест Россия 2011. Государство. Наука. Бизнес. Инвестиции
БиоИнвест Россия 2011. Государство. Наука. Бизнес. ИнвестицииБиоИнвест Россия 2011. Государство. Наука. Бизнес. Инвестиции
БиоИнвест Россия 2011. Государство. Наука. Бизнес. Инвестиции
 
BioInvest Russia-2011
BioInvest Russia-2011BioInvest Russia-2011
BioInvest Russia-2011
 
SlideShare
SlideShareSlideShare
SlideShare
 
Chelsea Hayman
Chelsea HaymanChelsea Hayman
Chelsea Hayman
 
Family gathering april 2011
Family gathering april 2011Family gathering april 2011
Family gathering april 2011
 
Traction story map plan
Traction   story map planTraction   story map plan
Traction story map plan
 
Slideshare
SlideshareSlideshare
Slideshare
 

Similar to Coffee script

Coffee scriptisforclosers nonotes
Coffee scriptisforclosers nonotesCoffee scriptisforclosers nonotes
Coffee scriptisforclosers nonotesBrandon Satrom
 
Real life-coffeescript
Real life-coffeescriptReal life-coffeescript
Real life-coffeescriptDavid Furber
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasminePaulo Ragonha
 
Ruby Metaprogramming
Ruby MetaprogrammingRuby Metaprogramming
Ruby MetaprogrammingThaichor Seng
 
CoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developersCoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developersMehdi Valikhani
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applicationselliando dias
 
CoffeeScript & Jasmine - MadJS February 2012
CoffeeScript & Jasmine - MadJS February 2012CoffeeScript & Jasmine - MadJS February 2012
CoffeeScript & Jasmine - MadJS February 2012Matt Gauger
 
Intro to Functional Programming
Intro to Functional ProgrammingIntro to Functional Programming
Intro to Functional ProgrammingJordan Parmer
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptForziatech
 
Intro to React
Intro to ReactIntro to React
Intro to ReactTroy Miles
 
GDI Seattle - Intro to JavaScript Class 1
GDI Seattle - Intro to JavaScript Class 1GDI Seattle - Intro to JavaScript Class 1
GDI Seattle - Intro to JavaScript Class 1Heather Rock
 

Similar to Coffee script (20)

Coffee scriptisforclosers nonotes
Coffee scriptisforclosers nonotesCoffee scriptisforclosers nonotes
Coffee scriptisforclosers nonotes
 
Real life-coffeescript
Real life-coffeescriptReal life-coffeescript
Real life-coffeescript
 
ES6: The Awesome Parts
ES6: The Awesome PartsES6: The Awesome Parts
ES6: The Awesome Parts
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
Ruby Metaprogramming
Ruby MetaprogrammingRuby Metaprogramming
Ruby Metaprogramming
 
Cucumber testing
Cucumber testingCucumber testing
Cucumber testing
 
Cucumber testing
Cucumber testingCucumber testing
Cucumber testing
 
test
testtest
test
 
CoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developersCoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developers
 
Ruby on Rails
Ruby on RailsRuby on Rails
Ruby on Rails
 
Wakanday JS201 Best Practices
Wakanday JS201 Best PracticesWakanday JS201 Best Practices
Wakanday JS201 Best Practices
 
PHP and Rich Internet Applications
PHP and Rich Internet ApplicationsPHP and Rich Internet Applications
PHP and Rich Internet Applications
 
Cucumber & BDD
Cucumber & BDDCucumber & BDD
Cucumber & BDD
 
CoffeeScript & Jasmine - MadJS February 2012
CoffeeScript & Jasmine - MadJS February 2012CoffeeScript & Jasmine - MadJS February 2012
CoffeeScript & Jasmine - MadJS February 2012
 
Coffeescript slides
Coffeescript slidesCoffeescript slides
Coffeescript slides
 
Intro to Functional Programming
Intro to Functional ProgrammingIntro to Functional Programming
Intro to Functional Programming
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
Quick coffeescript
Quick coffeescriptQuick coffeescript
Quick coffeescript
 
GDI Seattle - Intro to JavaScript Class 1
GDI Seattle - Intro to JavaScript Class 1GDI Seattle - Intro to JavaScript Class 1
GDI Seattle - Intro to JavaScript Class 1
 

Coffee script

  • 2. Me • Zarar Siddiqi • Agile Coach with a developer’s itch • http://www.linkedin.com/in/zararsiddiqi • zarar_siddiqi@epam.com • Confluence page for This Week @: • https://kb.epam.com/pages/viewpage.action?pageId=107875299 • Next week: Agile Games!
  • 3. Agenda • Why Bother? • Basic Concept • Simple But High ROI Features • Other Nice Features • Code Playground • Windows Installation • Examples • Conclusion (or something like it) • Discussion
  • 5. 1.1: LIBRARIES #1: JavaScript Use Exploding 1.2: MVVM, SINGLE-PAGE APPS 1.3: MOBILE 1.4: SERVER
  • 6. #2: Problems with JavaScript • Ambiguous constructs leading to verbosity • function, prototype, extend, var, (function() {}); • Error-prone with late visibility • Trailing commas, string concatenation, context binding, equality • Limited features • List comprehension, string interpolation, conditional modifiers • Namespace pollution • All <script> files loaded in one global scope • PHP Problems • Easy to get started; easy to go downhill
  • 7. The math is simple Lots of JS Easy to write messy JS Lots of messy JS
  • 9. How it works file.coffee Compile file.js page.html <script> tag Analogous to less for CSS - http://lesscss.org/
  • 10. Benefits • .coffee has less code to maintain – 35-45% less • Produces JSLint validated code (http://jslint.com) • http://javascript.crockford.com/code.html • Easy-to-read code (Influenced by Ruby, Python, Haskell) • Focuses on JavaScript: The Good Parts (Douglas Crockford): http://amzn.to/176RA4 • Written by smart people, very strong community support, mature (3.5 years) • Easy to unit test (Jasmine) - http://pivotal.github.io/jasmine/
  • 11. SIMPLE BUT HIGH ROI FEATURES
  • 12. #1: Defining classes - Some ways of defining objects in JavaScript: - Using function - Using prototype - var obj = {} Let’s look at some examples…
  • 13. Here’s one way… // Using a function function Apple (country) { this.country = country; this.color = "red"; this.getInfo = getAppleInfo; } function getAppleInfo() { return this.country + ' has ' + this.color + 'apples'.; }
  • 14. Here’s another… // Using the prototype function Apple (country) { this.country = country; this.color = "red"; } Apple.prototype.getInfo = function() { return this.country + ' has ' + this.color + 'apples'.; };
  • 15. This will work too… // Using object literals var apple = { country: "Sweden", color: "red", getInfo: function () { return this.country + ' has ' + this.color + 'apples'.; } }
  • 16. Equivalent CoffeeScript class class Apple constructor: (@country) -> @color = "red" getInfo: -> "{@country} has {@color} apples" class BakedApple extends Apple constructor: -> super(“Canada”) @color = “brown” // No method keyword // @ instead of this // Implicit assignment // Indentation // Sensible class declaration // Interpolation // Implicit returns // Easy inheritance model
  • 17. #2: The var problem Example 1 function foo() { var name = “Bob”; age = 29; } alert(name); alert(age); Example 2 function printTen() { for (i=0; i<10; i++) { console.log(i); } return true } printTen(); alert(i);
  • 18. CoffeeScript default scope is local CoffeeScript foo: -> name = "Bob" age = 29 JavaScript printTen: function() { var i, _i; for (i = _i = 0; _i <= 10; i = _i += 1) { console.log(i); } return true; } printTen(); alert(i); function foo() { var age, name; name = "Bob"; age = 29; } printTen: -> for i in [0..10] by 1 console.log i return true printTen() alert(i)
  • 19. #3: Outer Scope Referencing JavaScript function User(name) { this.name = name; } User.prototype.save = function() { var _this = this; $.post('/user/save', function(data){ $('.msg').html(_this.name+ "saved."); }); }; CoffeeScript class User constructor: (@name) -> save: -> $.post '/user/save', (data) => $('.msg').html("#{@name} saved.")
  • 20. #4: Object Literal Readability / Writability CoffeeScript config = user: id: 'jsmith' name: first: 'John' last: 'Smith' password: 'pass ' email: 'jsmith@example.com' host: 'localhost' port: 3306 conn: -> App.connect() JavaScript config = { user: { id: 'jsmith', name: { first: 'John', last: 'Smith' }, password: 'pass', email: 'jsmith@example.com' }, host: 'localhost', port: 3306, conn: function() { return App.connect(); } };
  • 21. #5: Testing Equality "" == "0" // false 0 == "" // true 0 == "0" // true false == "false" // false false == "0" // true false == undefined // false false == null // false null == undefined // true " trn" == 0 // true Type Coercion! Solution: Use the is and isnt keywords which compare without coercing and are more readable: if a is b doSomething()
  • 22. SYNTACTIC SUGAR “make things easier to read or to express.”
  • 23. A spoonful of sugar… # Existence checking if happy? console.log "clap your hands" # Skip null checks truck.getTires()?.change() # Tuple-like assignments [a, b] = [1, 2] if (truck.getTires() != null) truck.getTires().change() if (typeof happy !== "undefined" && happy !== null)
  • 24. Some more sugar… # Iterate over a list with index for item, i in someList alert “Item #{i} is #{item}“ # Conditional modifiers # Conditional modifiers turnOn() if buttonPressed is true status = 'expired' unless withinRange()
  • 25. A whole jar of sugar… • http://coffeescript.org/
  • 27. Installation After downloading and installing NodeJS from http://nodejs.org/download/ Execute following from command prompt: C:>npm -g install coffee-script C:>coffee coffee>
  • 29. As with everything… • Use the right tool for the right job • If it’s a small piece of JS, don’t bother. If it’s a JS-heavy project, consider it • Philosophical Debate: Highly disciplined developers following a style guide vs. A language that helps standardize the produced code
  • 30. Resources • CoffeeScript Home Page • http://coffeescript.org/ • JS2Coffee (Coffee2JS) • http://js2coffee.org/ • Should you learn CoffeeScript? • http://net.tutsplus.com/articles/interviews/should-you-learn- coffeescript/ • Google Search – CoffeeScript Sucks • http://goo.gl/MNQrY • Brendan Eich • https://brendaneich.com/2011/05/my-jsconf-us-presentation/ • The Little Book on CoffeeScript • http://arcturo.github.io/library/coffeescript/

Editor's Notes

  1. LibrariesUsed by pretty much everyone for even the simplest use caseUsed to the point where they’re a crutch – need jQuery for everything (add a CSS class name to a div)54% of websites have one of these librariesMVVMModel and view aspects are shifted to JS, allowing for responsive, rich UI applicationsInstead of the occasional &lt;script&gt; tag mixed in with your HTML, you’re basically writing our app in JSUSA Today, Walmart, Airbnb, Souncloud, Hulu, Wordpress, Disqus, Khan AcademyMobileHTML5 is the most popular choice for write-once-deploy anywhere applications Transferable skill-set from web to mobile – varying successPhoneGap now called CordovaMarmalade is the exceptionServerLast but not leastHigh volume applications demanding low-latency, strong failover (e.g., APIs) are being written using JS
  2. Constructsfunction can be used to describe a class or a methodprototype vs. extend confusion regarding class creationvar can be used to define an object in global and local scope, function wrappingError-proneContext binding leads to function $.bindAll, bind – every library has themPHP ProblemsEasy to get startedEasy to go downhillThat’s when the pain strikes
  3. CoffeeScript doesn’t quite come to the rescue, but more to the aid of those developers writing extensive JavaScript applications that require long-term maintenance.
  4. A coffee file translates to a js file (by default)That js file is included in the pageCreated by Jeremy Ashkenas (Backbone)3.5 years old
  5. Crockford: Inventor of JSONGood parts: functions, loose typing, dynamic objects, object literal notationBad parts: scoping, convoluted inheritance modelMore Ruby, Python developers are writing JavaScript, and a need to improve its production has emerged
  6. - Looking at any code base you’ll find instances of each one
  7. No braces!Implicit assignment (think Backbone models)@ instead of this - Ruby
  8. Namespace pollution – memory leaks.
  9. It is an extra stepDebuggingSource Maps