際際滷

際際滷Share a Scribd company logo
CoffeeScript
                          Like JavaScript, but without the horrible.




Sunday, 27 November, 11
Burke Libbey
                          Me   @burkelibbey




Sunday, 27 November, 11
The   5   Second Pitch




Sunday, 27 November, 11
var foo = function() {
                            JavaScript     return "bar";
                                         }




                          CoffeeScript   foo = -> "bar"




Sunday, 27 November, 11
Sold! What did I just buy?




Sunday, 27 November, 11
CoffeeScript is a little language
            that compiles into JavaScript
                             Jeremy Ashkenas, CoffeeScript author




Sunday, 27 November, 11
foo = -> "bar"




                          CoffeeScript Compiler



                           (function() {
                             var foo;
                             foo = function() {
                                  return "bar";
                             };
                           }).call(this);




Sunday, 27 November, 11
Whats wrong with JavaScript?


                          Browser inconsistencies

                          Terrible DOM API

                          Redundant syntax




Sunday, 27 November, 11
Whats wrong with JavaScript?


                             Browser inconsistencies

                             Terrible DOM API

                             Redundant syntax


               Most of the issues people have with JavaScript
                     boil down to these three points.

Sunday, 27 November, 11
Whats wrong with JavaScript?


                                Browser inconsistencies

                                Terrible DOM API

                                Redundant syntax


                   jQuery does a fantastic job of shielding you
                                from these two.

Sunday, 27 November, 11
Whats wrong with JavaScript?


                               Browser inconsistencies

                               Terrible DOM API

                               Redundant syntax



                          CoffeeScript fixes this one.


Sunday, 27 November, 11
So whats wrong with the syntax?


                                         function(x) {
                                           return x * x;
                                         }



                          For a functional language, having to write function
                          and return everywhere is more than a little strange.


Sunday, 27 November, 11
Anonymous Function Syntax

                          JavaScript   function(x) { return x * x; }

                            Scheme     (lambda (x) (* x x))

                             Erlang    fun(X) -> X * X end.

                    CoffeeScript       (x) -> x * x

                            Haskell    x -> x * x

                            Clojure    #(* % %)

Sunday, 27 November, 11
Im a masochist, and I like
                   typing a lot. Give me another
                              reason.



Sunday, 27 November, 11
Rails 3.1 includes CoffeeScript
                        by default.



Sunday, 27 November, 11
...to the chagrin of hypocrites the
                     world over.



Sunday, 27 November, 11
Sunday, 27 November, 11
Fighting Rails is usually doomed
                      to failure.



Sunday, 27 November, 11
So just suck it up and learn
                                 CoffeeScript.



Sunday, 27 November, 11
Without further ado:
                  CoffeeScript Whirlwind tour



Sunday, 27 November, 11
three = -> 3

                          square = (x) -> x * x

                              add = (x, y)
                                x + y




Sunday, 27 November, 11
Default values!
        fill = (container, liquid = "coffee") ->
          "Filling the #{container} with #{liquid}..."

                          ...and string interpolation!




Sunday, 27 November, 11
YAML-like hash literals work
                                kids =
                                  brother:
                                    name: "Max"
                                    age: 11
                                  sister:
                                    name: "Ida"
                                    age: 9




Sunday, 27 November, 11
Never type var again!
                             CoffeeScript does it for you.




Sunday, 27 November, 11
mood = greatlyImproved if singing




Sunday, 27 November, 11
if happy and knowsIt
                            clapsHands()
                            chaChaCha()
                          else
                            showIt()




Sunday, 27 November, 11
date = if friday then sue else jill




Sunday, 27 November, 11
options or= defaults




Sunday, 27 November, 11
Im out of slides. Time for
                                live-coding!



Sunday, 27 November, 11
Thanks!




Sunday, 27 November, 11
Ad

Recommended

Rails 3.1
Rails 3.1
Lori Olson
Core Data in Motion
Core Data in Motion
Lori Olson
CoffeeScript By Example
CoffeeScript By Example
Christopher Bartling
Learn Ruby by Reading the Source
Learn Ruby by Reading the Source
Burke Libbey
Form project why is the sky blue and other questions
Form project why is the sky blue and other questions
aakashm
Javascript - How to avoid the bad parts
Javascript - How to avoid the bad parts
Mikko Ohtamaa
The CoffeeScript Edge
The CoffeeScript Edge
TrevorBurnham
Cloud9 IDE Talk at meet.js Pozna
Cloud9 IDE Talk at meet.js Pozna
zefhemel
Pocket Knife JS
Pocket Knife JS
Diogo Antunes
Coffee Script
Coffee Script
Michal Taberski
Javascript Basics - part 1
Javascript Basics - part 1
Kasia Drzyzga
CoffeeScript-Ruby-Tuesday
CoffeeScript-Ruby-Tuesday
Eddie Kao
Rcos presentation
Rcos presentation
mskmoorthy
Javascript, Do you speak it!
Javascript, Do you speak it!
Victor Porof
Enterprise javascriptsession1
Enterprise javascriptsession1
Troy Miles
A Re-Introduction to JavaScript
A Re-Introduction to JavaScript
Simon Willison
02 JavaScript Syntax
02 JavaScript Syntax
Ynon Perek
Javascript the Language of the Web
Javascript the Language of the Web
andersjanmyr
Coffeescript
Coffeescript
Scott Motte
JavaScript Secrets
JavaScript Secrets
Patrick Sheridan
Coffee scriptisforclosers nonotes
Coffee scriptisforclosers nonotes
Brandon Satrom
CoffeeScript
CoffeeScript
Soren Harner
Js in the open
Js in the open
Victor Porof
CoffeeScript
CoffeeScript
Eddie Kao
D5 crazy speed web development
D5 crazy speed web development
NAVER D2
JSLent: give it up for JavaScript
JSLent: give it up for JavaScript
BigBlueHat
CoffeeScript - JavaScript in a simple way
CoffeeScript - JavaScript in a simple way
Lim Chanmann
PyJS intro
PyJS intro
Demix
Nix: What even is it though?
Nix: What even is it though?
Burke Libbey
Ruby Internals
Ruby Internals
Burke Libbey

More Related Content

Similar to Coffeescript (20)

Pocket Knife JS
Pocket Knife JS
Diogo Antunes
Coffee Script
Coffee Script
Michal Taberski
Javascript Basics - part 1
Javascript Basics - part 1
Kasia Drzyzga
CoffeeScript-Ruby-Tuesday
CoffeeScript-Ruby-Tuesday
Eddie Kao
Rcos presentation
Rcos presentation
mskmoorthy
Javascript, Do you speak it!
Javascript, Do you speak it!
Victor Porof
Enterprise javascriptsession1
Enterprise javascriptsession1
Troy Miles
A Re-Introduction to JavaScript
A Re-Introduction to JavaScript
Simon Willison
02 JavaScript Syntax
02 JavaScript Syntax
Ynon Perek
Javascript the Language of the Web
Javascript the Language of the Web
andersjanmyr
Coffeescript
Coffeescript
Scott Motte
JavaScript Secrets
JavaScript Secrets
Patrick Sheridan
Coffee scriptisforclosers nonotes
Coffee scriptisforclosers nonotes
Brandon Satrom
CoffeeScript
CoffeeScript
Soren Harner
Js in the open
Js in the open
Victor Porof
CoffeeScript
CoffeeScript
Eddie Kao
D5 crazy speed web development
D5 crazy speed web development
NAVER D2
JSLent: give it up for JavaScript
JSLent: give it up for JavaScript
BigBlueHat
CoffeeScript - JavaScript in a simple way
CoffeeScript - JavaScript in a simple way
Lim Chanmann
PyJS intro
PyJS intro
Demix
Javascript Basics - part 1
Javascript Basics - part 1
Kasia Drzyzga
CoffeeScript-Ruby-Tuesday
CoffeeScript-Ruby-Tuesday
Eddie Kao
Rcos presentation
Rcos presentation
mskmoorthy
Javascript, Do you speak it!
Javascript, Do you speak it!
Victor Porof
Enterprise javascriptsession1
Enterprise javascriptsession1
Troy Miles
A Re-Introduction to JavaScript
A Re-Introduction to JavaScript
Simon Willison
02 JavaScript Syntax
02 JavaScript Syntax
Ynon Perek
Javascript the Language of the Web
Javascript the Language of the Web
andersjanmyr
Coffee scriptisforclosers nonotes
Coffee scriptisforclosers nonotes
Brandon Satrom
CoffeeScript
CoffeeScript
Eddie Kao
D5 crazy speed web development
D5 crazy speed web development
NAVER D2
JSLent: give it up for JavaScript
JSLent: give it up for JavaScript
BigBlueHat
CoffeeScript - JavaScript in a simple way
CoffeeScript - JavaScript in a simple way
Lim Chanmann
PyJS intro
PyJS intro
Demix

More from Burke Libbey (7)

Nix: What even is it though?
Nix: What even is it though?
Burke Libbey
Ruby Internals
Ruby Internals
Burke Libbey
The Enterprise Strikes Back
The Enterprise Strikes Back
Burke Libbey
Fuck Yeah Nouns
Fuck Yeah Nouns
Burke Libbey
Rails Performance Tuning
Rails Performance Tuning
Burke Libbey
The Enterprise Strikes Back
The Enterprise Strikes Back
Burke Libbey
Ruby's Object Model: Metaprogramming and other Magic
Ruby's Object Model: Metaprogramming and other Magic
Burke Libbey
Nix: What even is it though?
Nix: What even is it though?
Burke Libbey
The Enterprise Strikes Back
The Enterprise Strikes Back
Burke Libbey
Fuck Yeah Nouns
Fuck Yeah Nouns
Burke Libbey
Rails Performance Tuning
Rails Performance Tuning
Burke Libbey
The Enterprise Strikes Back
The Enterprise Strikes Back
Burke Libbey
Ruby's Object Model: Metaprogramming and other Magic
Ruby's Object Model: Metaprogramming and other Magic
Burke Libbey
Ad

Recently uploaded (20)

Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
Addressing Evolving AI Model Challenges Through Memory and Storage, a Prese...
Addressing Evolving AI Model Challenges Through Memory and Storage, a Prese...
Edge AI and Vision Alliance
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
June Patch Tuesday
June Patch Tuesday
Ivanti
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
Addressing Evolving AI Model Challenges Through Memory and Storage, a Prese...
Addressing Evolving AI Model Challenges Through Memory and Storage, a Prese...
Edge AI and Vision Alliance
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
June Patch Tuesday
June Patch Tuesday
Ivanti
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
Ad

Coffeescript

  • 1. CoffeeScript Like JavaScript, but without the horrible. Sunday, 27 November, 11
  • 2. Burke Libbey Me @burkelibbey Sunday, 27 November, 11
  • 3. The 5 Second Pitch Sunday, 27 November, 11
  • 4. var foo = function() { JavaScript return "bar"; } CoffeeScript foo = -> "bar" Sunday, 27 November, 11
  • 5. Sold! What did I just buy? Sunday, 27 November, 11
  • 6. CoffeeScript is a little language that compiles into JavaScript Jeremy Ashkenas, CoffeeScript author Sunday, 27 November, 11
  • 7. foo = -> "bar" CoffeeScript Compiler (function() { var foo; foo = function() { return "bar"; }; }).call(this); Sunday, 27 November, 11
  • 8. Whats wrong with JavaScript? Browser inconsistencies Terrible DOM API Redundant syntax Sunday, 27 November, 11
  • 9. Whats wrong with JavaScript? Browser inconsistencies Terrible DOM API Redundant syntax Most of the issues people have with JavaScript boil down to these three points. Sunday, 27 November, 11
  • 10. Whats wrong with JavaScript? Browser inconsistencies Terrible DOM API Redundant syntax jQuery does a fantastic job of shielding you from these two. Sunday, 27 November, 11
  • 11. Whats wrong with JavaScript? Browser inconsistencies Terrible DOM API Redundant syntax CoffeeScript fixes this one. Sunday, 27 November, 11
  • 12. So whats wrong with the syntax? function(x) { return x * x; } For a functional language, having to write function and return everywhere is more than a little strange. Sunday, 27 November, 11
  • 13. Anonymous Function Syntax JavaScript function(x) { return x * x; } Scheme (lambda (x) (* x x)) Erlang fun(X) -> X * X end. CoffeeScript (x) -> x * x Haskell x -> x * x Clojure #(* % %) Sunday, 27 November, 11
  • 14. Im a masochist, and I like typing a lot. Give me another reason. Sunday, 27 November, 11
  • 15. Rails 3.1 includes CoffeeScript by default. Sunday, 27 November, 11
  • 16. ...to the chagrin of hypocrites the world over. Sunday, 27 November, 11
  • 18. Fighting Rails is usually doomed to failure. Sunday, 27 November, 11
  • 19. So just suck it up and learn CoffeeScript. Sunday, 27 November, 11
  • 20. Without further ado: CoffeeScript Whirlwind tour Sunday, 27 November, 11
  • 21. three = -> 3 square = (x) -> x * x add = (x, y) x + y Sunday, 27 November, 11
  • 22. Default values! fill = (container, liquid = "coffee") -> "Filling the #{container} with #{liquid}..." ...and string interpolation! Sunday, 27 November, 11
  • 23. YAML-like hash literals work kids = brother: name: "Max" age: 11 sister: name: "Ida" age: 9 Sunday, 27 November, 11
  • 24. Never type var again! CoffeeScript does it for you. Sunday, 27 November, 11
  • 25. mood = greatlyImproved if singing Sunday, 27 November, 11
  • 26. if happy and knowsIt clapsHands() chaChaCha() else showIt() Sunday, 27 November, 11
  • 27. date = if friday then sue else jill Sunday, 27 November, 11
  • 28. options or= defaults Sunday, 27 November, 11
  • 29. Im out of slides. Time for live-coding! Sunday, 27 November, 11