SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Downloaden Sie, um offline zu lesen
COFFEESCRIPT!
          A OPINIONATED INTRODUCTION
by: joe fleming | twitter: @w33ble | github: w33ble
If I'm wrong, call me on it
If you have a question, ask
WHAT IS
    COFFEESCRIPT?
"A little language that compiles into javascript"
         Takes the pain out of javascript
BASIC RULES
Whitespace matters
Functions have a different syntax
Everything is an expression
Scope is handled automatically
RESOURCES
Coffeescript.org
  Great docs with table of contents
  Interactive live shell
Coffeescript meet Backbone
  Easy way to see it in action
WELL FORMATTED JAVASCRIPT
vrpro ={
 a esn
   nm:'o feig,
   ae je lmn'
   gtu:'3be,
   ihb w3l'
   itrss ['ofecit,'ulm tx' 'oej']
   neet:  cfesrp' sbie et, nd.s
};

fnto mkAeoe(b){
 ucin aewsm oj
   ojaeoe=tu;
   b.wsm   re
};

fnto gtae(b){
 ucin eNm oj
   rtr ojnm;
   eun b.ae
}

mkAeoepro)
 aewsm(esn;

cnoelggtaepro);
 osl.o(eNm(esn)
SLIGHTLY MODIFIED JAVASCRIPT
Functions become closures assigned to variables
vrpro ={
 a esn
   nm:'o feig,
   ae je lmn'
   gtu:'3be,
   ihb w3l'
   itrss ['ofecit,'ulm tx' 'oej']
   neet:  cfesrp' sbie et, nd.s
};

vrmkAeoe=fnto (b){
 a aewsm   ucin oj
   ojaeoe=tu;
   b.wsm   re
};

vrgtae=fnto(b){
 a eNm   ucinoj
   rtr ojnm;
   eun b.ae
}

mkAeoepro)
 aewsm(esn;

cnoelggtaepro);
 osl.o(eNm(esn)
CONVERT TO COFFEESCRIPT
          Step 1: Remove v r
                          a
pro ={
 esn
   nm:'o feig,
   ae je lmn'
   titr '3be,
   wte: w3l'
   gtu:'3be,
   ihb w3l'
   itrss ['ofecit,'ulm tx' 'oej']
   neet:  cfesrp' sbie et, nd.s
};

mkAeoe=fnto (b){
 aewsm   ucin oj
   ojaeoe=tu;
   b.wsm   re
}

gtae=fnto (b){
 eNm   ucin oj
   rtr ojnm;
   eun b.ae
}

mkAeoepro)
 aewsm(esn;

cnoelggtaepro);
 osl.o(eNm(esn)
CONVERT TO COFFEESCRIPT
Step 2: change f n t o syntax & remove brackets
                ucin
pro ={
 esn
   nm:'o feig,
   ae je lmn'
   titr '3be,
   wte: w3l'
   gtu:'3be,
   ihb w3l'
   itrss ['ofecit,'ulm tx' 'oej']
   neet:  cfesrp' sbie et, nd.s
};

mkAeoe=(b)-g;
 aewsm   oj &t
   ojaeoe=tu;
   b.wsm   re

gtae=(b)-g;
 eNm   oj &t
   rtr ojnm;
   eun b.ae

mkAeoepro)
 aewsm(esn;

cnoelggtaepro);
 osl.o(eNm(esn)


        This compiles! But why stop here?
CONVERT TO COFFEESCRIPT
Remove some ugly bits; brackets and semi-colons
pro =
 esn
   nm:'o feig,
   ae je lmn'
   titr '3be,
   wte: w3l'
   gtu:'3be,
   ihb w3l'
   itrss ['ofecit,'ulm tx' 'oej']
   neet:  cfesrp' sbie et, nd.s

mkAeoe=(b)-g;
 aewsm   oj &t
   ojaeoe=tu
   b.wsm   re

gtae=(b)-g;
 eNm   oj &t
   rtr ojnm
   eun b.ae

mkAeoepro)
 aewsm(esn

cnoelggtaepro)
 osl.o(eNm(esn)
CONVERT TO COFFEESCRIPT
    Remove parens, commas and returns
pro =
 esn
   nm:'o feig
   ae je lmn'
   titr '3be
   wte: w3l'
   gtu:'3be
   ihb w3l'
   itrss ['ofecit,'ulm tx' 'oej']
   neet:  cfesrp' sbie et, nd.s

mkAeoe=(b)-g;
 aewsm   oj &t
   ojaeoe=tu
   b.wsm   re

gtae=(b)-g;
 eNm   oj &t
   ojnm
   b.ae

mkAeoepro
 aewsm esn

cnoelggtaepro
 osl.o eNm esn


                 Aw yeah!
WHY'S IT GREAT?
READS LIKE ENGLISH
atetctd=tu uls acuti fle
 uhniae  re nes con s as

i nmi 1
 f u s 3
   aet"inr"
    lr wne!

wne =tu i pc i [1,3,8 ]
 inr  re f ik n 2 7 8
EASY TO UNDERSTAND
 us
    SHORTCUTS
nm =[.1]
    1.0

aet"yfvrt nme i #nm[]"
 lr M aoie ubr s {us3}

casPro
 ls esn
  cntutr (nm)-
  osrco: @ae >
  gtae -
  eNm: >
   @ae
   nm
CLEAN SYNTAX
  Well formatted code
    Easier to read
    Easier to maintain
  Less typing, less errors
  Fun to write
MY FAVORITE SUGAR
BLOCK STRINGS & INTERPOLATION
MY FAVORITE SUGAR
FUNCTION BINDING AKA "FAT ARROW"
MY FAVORITE SUGAR
  THE EXISTENTIAL OPERATOR
MY FAVORITE SUGAR
     CLASS SYNTAX
ECMASCRIPT 6
WITHOUT THE WAIT
   Still generates ES5 code
      Works like an ES6 shim
MANY "WEIRD" PARTS
  ARE OPTIONAL
  Omitting r t r
            eun
  Using i , i n to , a detc
         s s o, r n,
  Removing commas in arrays
  Removing commas and brackets in objects
  Dropping parens on function calls
LET'S SEE SOME
  EXAMPLES
EXPRESS (NODE.JS)
BACKBONE
CLASS INHERITANCE
  Coffeescript.org
    ES6 style class inheritance
    Makes s p rvery easy to use
             ue
  Simpler class
    Class like you're probably used to
    No b n or e t n required
          id      xed
  Fair JS version
    Creates b n and e t n smethods
                id    xed
    Still calls s p r
                 ue
    Whole lotta mess
COFFEESCRIPT IS
    GREAT
  NO DOWNSIDES TO USING IT
ANOTHER SYNTAX TO
     LEARN
   Not pure JS
   Could complicate hiring/consulting
   Pretty easy if you know JS
   Maybe you should hire better
REQUIRES COMPILING
            (MOST OF THE TIME)
Adds another step to development and deployment
Build process: c f e , grunt, make/jake, etc
                 ofe
Asset pipeline: connect-assets
Runtimes: n d - e
            oedv
Hosting: heroku, nodester, nodejitsu
DEBUGGING
Compiled into javascript
Runtime errors reference js code
Editor plugins ease this
DON'T STOP WITH
  JAVASCRIPT
HTML
Haml pretty much started it
Slim made it cleaner
Jade brought it to JS
Coffeekup coffeescript as markup
JADE
Full template library
   Variables, conditionals, inheritance, etc
Client-side or server-side
CSS
Sass /SCSS/Sassy CSS started this
Less made it universal
Stylus brought it to JS
STYLUS
Variables, mixins, calculations, conditionals
Everything is optional (except the whitespace)
  Mix and match freely
THANKS!


           joe fleming
twitter: @w33ble | github: w33ble

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction To Programming in GNU-LINUX
Introduction To Programming in GNU-LINUXIntroduction To Programming in GNU-LINUX
Introduction To Programming in GNU-LINUXIrfan Ahmed
 
Ember.js Meetup Brussels 31/10/2013
Ember.js Meetup Brussels 31/10/2013Ember.js Meetup Brussels 31/10/2013
Ember.js Meetup Brussels 31/10/2013Hstry
 
Introduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme developmentIntroduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme developmentJames Bundey
 
CasperJs Enjoy Functional Testing
CasperJs Enjoy Functional TestingCasperJs Enjoy Functional Testing
CasperJs Enjoy Functional TestingFabien POMEROL
 
Virtual Infrastructure
Virtual InfrastructureVirtual Infrastructure
Virtual InfrastructureBryan McLellan
 
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...andreaslubbe
 
Testing MeteorJS using CasperJS
Testing MeteorJS using CasperJSTesting MeteorJS using CasperJS
Testing MeteorJS using CasperJSStephan Hochhaus
 
Automating WordPress Theme Development
Automating WordPress Theme DevelopmentAutomating WordPress Theme Development
Automating WordPress Theme DevelopmentHardeep Asrani
 
Playing With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.jsPlaying With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.jsMike Hagedorn
 
Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Hervé Vũ Roussel
 
(WHAT) To Do or Not To Do: Staying Up To Date with PHP Versions
(WHAT) To Do or Not To Do: Staying Up To Date with PHP Versions(WHAT) To Do or Not To Do: Staying Up To Date with PHP Versions
(WHAT) To Do or Not To Do: Staying Up To Date with PHP VersionsAbu Ashraf Masnun
 
Automatiser le setup de vos projets avec Eclipse Oomph
Automatiser le setup de vos projets avec Eclipse OomphAutomatiser le setup de vos projets avec Eclipse Oomph
Automatiser le setup de vos projets avec Eclipse OomphJérémie Bresson
 
Backbone the Good Parts
Backbone the Good PartsBackbone the Good Parts
Backbone the Good PartsRenan Carvalho
 
Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...
Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...
Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...Puppet
 
Reasons To Love Ruby
Reasons To Love RubyReasons To Love Ruby
Reasons To Love RubyBen Scheirman
 
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivosti
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivostiRiki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivosti
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivostiDevelcz
 

Was ist angesagt? (19)

Introduction To Programming in GNU-LINUX
Introduction To Programming in GNU-LINUXIntroduction To Programming in GNU-LINUX
Introduction To Programming in GNU-LINUX
 
Ember.js Meetup Brussels 31/10/2013
Ember.js Meetup Brussels 31/10/2013Ember.js Meetup Brussels 31/10/2013
Ember.js Meetup Brussels 31/10/2013
 
Introduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme developmentIntroduction to using Grunt & Bower with WordPress theme development
Introduction to using Grunt & Bower with WordPress theme development
 
CasperJs Enjoy Functional Testing
CasperJs Enjoy Functional TestingCasperJs Enjoy Functional Testing
CasperJs Enjoy Functional Testing
 
Virtual Infrastructure
Virtual InfrastructureVirtual Infrastructure
Virtual Infrastructure
 
CouchApp - Build scalable web applications and relax
CouchApp - Build scalable web applications and relaxCouchApp - Build scalable web applications and relax
CouchApp - Build scalable web applications and relax
 
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
 
MLBlock
MLBlockMLBlock
MLBlock
 
Testing MeteorJS using CasperJS
Testing MeteorJS using CasperJSTesting MeteorJS using CasperJS
Testing MeteorJS using CasperJS
 
Automating WordPress Theme Development
Automating WordPress Theme DevelopmentAutomating WordPress Theme Development
Automating WordPress Theme Development
 
Playing With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.jsPlaying With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.js
 
Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS
 
(WHAT) To Do or Not To Do: Staying Up To Date with PHP Versions
(WHAT) To Do or Not To Do: Staying Up To Date with PHP Versions(WHAT) To Do or Not To Do: Staying Up To Date with PHP Versions
(WHAT) To Do or Not To Do: Staying Up To Date with PHP Versions
 
Automatiser le setup de vos projets avec Eclipse Oomph
Automatiser le setup de vos projets avec Eclipse OomphAutomatiser le setup de vos projets avec Eclipse Oomph
Automatiser le setup de vos projets avec Eclipse Oomph
 
Backbone the Good Parts
Backbone the Good PartsBackbone the Good Parts
Backbone the Good Parts
 
CasperJS
CasperJSCasperJS
CasperJS
 
Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...
Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...
Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...
 
Reasons To Love Ruby
Reasons To Love RubyReasons To Love Ruby
Reasons To Love Ruby
 
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivosti
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivostiRiki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivosti
Riki Fridrich - Grunt, Gulp a spol. - Automatizáciou k maximalizácii lenivosti
 

Andere mochten auch

Introduction to CoffeeScript
Introduction to CoffeeScriptIntroduction to CoffeeScript
Introduction to CoffeeScriptStalin Thangaraj
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScriptNone
 
Coffee script grunt
Coffee script gruntCoffee script grunt
Coffee script gruntKien Pham
 
Ruby Made Simple: Blocks Plus Iterators
Ruby Made Simple: Blocks Plus IteratorsRuby Made Simple: Blocks Plus Iterators
Ruby Made Simple: Blocks Plus IteratorsJohn Schmidt
 

Andere mochten auch (6)

CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
Introduction to CoffeeScript
Introduction to CoffeeScriptIntroduction to CoffeeScript
Introduction to CoffeeScript
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
Coffee script grunt
Coffee script gruntCoffee script grunt
Coffee script grunt
 
Ruby Made Simple: Blocks Plus Iterators
Ruby Made Simple: Blocks Plus IteratorsRuby Made Simple: Blocks Plus Iterators
Ruby Made Simple: Blocks Plus Iterators
 
Coffee Script
Coffee ScriptCoffee Script
Coffee Script
 

Ähnlich wie Coffeescript: An Opinionated Introduction

CoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developersCoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developersMehdi Valikhani
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnitEdorian
 
Real life-coffeescript
Real life-coffeescriptReal life-coffeescript
Real life-coffeescriptDavid Furber
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnitEdorian
 
Hubot: a look inside our robot friend
Hubot: a look inside our robot friendHubot: a look inside our robot friend
Hubot: a look inside our robot friendajacksified
 
The state of PHPUnit
The state of PHPUnitThe state of PHPUnit
The state of PHPUnitEdorian
 
Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Peter Higgins
 
Fluent Refactoring (Lone Star Ruby Conf 2013)
Fluent Refactoring (Lone Star Ruby Conf 2013)Fluent Refactoring (Lone Star Ruby Conf 2013)
Fluent Refactoring (Lone Star Ruby Conf 2013)Sam Livingston-Gray
 
Simplify writing code with deliberate commits
Simplify writing code with deliberate commitsSimplify writing code with deliberate commits
Simplify writing code with deliberate commitsJoel Chippindale
 
CQL3 and Data Modeling 101 with Apache Cassandra
CQL3 and Data Modeling 101 with Apache CassandraCQL3 and Data Modeling 101 with Apache Cassandra
CQL3 and Data Modeling 101 with Apache CassandraChris McEniry
 
Simplify writing code with deliberate commits - London Python Meetup
Simplify writing code with deliberate commits - London Python MeetupSimplify writing code with deliberate commits - London Python Meetup
Simplify writing code with deliberate commits - London Python MeetupJoel Chippindale
 
Django Toolbox
Django ToolboxDjango Toolbox
Django Toolboxpythonsd
 
Angular.js + Rails at WeWork or: The Accidental Feature
Angular.js + Rails at WeWork or: The Accidental FeatureAngular.js + Rails at WeWork or: The Accidental Feature
Angular.js + Rails at WeWork or: The Accidental FeatureJonathan Magen
 
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"epamspb
 
One page app with AngularJS
One page app with AngularJSOne page app with AngularJS
One page app with AngularJSAdam Štipák
 
Writing DSLs with Parslet - Wicked Good Ruby Conf
Writing DSLs with Parslet - Wicked Good Ruby ConfWriting DSLs with Parslet - Wicked Good Ruby Conf
Writing DSLs with Parslet - Wicked Good Ruby ConfJason Garber
 
Making JavaScript Libraries More Approachable
Making JavaScript Libraries More ApproachableMaking JavaScript Libraries More Approachable
Making JavaScript Libraries More ApproachablePamela Fox
 

Ähnlich wie Coffeescript: An Opinionated Introduction (20)

CoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developersCoffeeScript, An Introduction for Nodejs developers
CoffeeScript, An Introduction for Nodejs developers
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
 
Real life-coffeescript
Real life-coffeescriptReal life-coffeescript
Real life-coffeescript
 
The State of PHPUnit
The State of PHPUnitThe State of PHPUnit
The State of PHPUnit
 
Hubot: a look inside our robot friend
Hubot: a look inside our robot friendHubot: a look inside our robot friend
Hubot: a look inside our robot friend
 
The state of PHPUnit
The state of PHPUnitThe state of PHPUnit
The state of PHPUnit
 
Es6 hackathon
Es6 hackathonEs6 hackathon
Es6 hackathon
 
Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.Your Library Sucks, and why you should use it.
Your Library Sucks, and why you should use it.
 
Fluent Refactoring (Lone Star Ruby Conf 2013)
Fluent Refactoring (Lone Star Ruby Conf 2013)Fluent Refactoring (Lone Star Ruby Conf 2013)
Fluent Refactoring (Lone Star Ruby Conf 2013)
 
Simplify writing code with deliberate commits
Simplify writing code with deliberate commitsSimplify writing code with deliberate commits
Simplify writing code with deliberate commits
 
CQL3 and Data Modeling 101 with Apache Cassandra
CQL3 and Data Modeling 101 with Apache CassandraCQL3 and Data Modeling 101 with Apache Cassandra
CQL3 and Data Modeling 101 with Apache Cassandra
 
ES6: Features + Rails
ES6: Features + RailsES6: Features + Rails
ES6: Features + Rails
 
Simplify writing code with deliberate commits - London Python Meetup
Simplify writing code with deliberate commits - London Python MeetupSimplify writing code with deliberate commits - London Python Meetup
Simplify writing code with deliberate commits - London Python Meetup
 
Django Toolbox
Django ToolboxDjango Toolbox
Django Toolbox
 
Angular.js + Rails at WeWork or: The Accidental Feature
Angular.js + Rails at WeWork or: The Accidental FeatureAngular.js + Rails at WeWork or: The Accidental Feature
Angular.js + Rails at WeWork or: The Accidental Feature
 
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
 
One page app with AngularJS
One page app with AngularJSOne page app with AngularJS
One page app with AngularJS
 
Writing DSLs with Parslet - Wicked Good Ruby Conf
Writing DSLs with Parslet - Wicked Good Ruby ConfWriting DSLs with Parslet - Wicked Good Ruby Conf
Writing DSLs with Parslet - Wicked Good Ruby Conf
 
C to perl binding
C to perl bindingC to perl binding
C to perl binding
 
Making JavaScript Libraries More Approachable
Making JavaScript Libraries More ApproachableMaking JavaScript Libraries More Approachable
Making JavaScript Libraries More Approachable
 

Coffeescript: An Opinionated Introduction

  • 1. COFFEESCRIPT! A OPINIONATED INTRODUCTION by: joe fleming | twitter: @w33ble | github: w33ble
  • 2. If I'm wrong, call me on it If you have a question, ask
  • 3. WHAT IS COFFEESCRIPT? "A little language that compiles into javascript" Takes the pain out of javascript
  • 4. BASIC RULES Whitespace matters Functions have a different syntax Everything is an expression Scope is handled automatically
  • 5. RESOURCES Coffeescript.org Great docs with table of contents Interactive live shell Coffeescript meet Backbone Easy way to see it in action
  • 6. WELL FORMATTED JAVASCRIPT vrpro ={ a esn nm:'o feig, ae je lmn' gtu:'3be, ihb w3l' itrss ['ofecit,'ulm tx' 'oej'] neet: cfesrp' sbie et, nd.s }; fnto mkAeoe(b){ ucin aewsm oj ojaeoe=tu; b.wsm re }; fnto gtae(b){ ucin eNm oj rtr ojnm; eun b.ae } mkAeoepro) aewsm(esn; cnoelggtaepro); osl.o(eNm(esn)
  • 7. SLIGHTLY MODIFIED JAVASCRIPT Functions become closures assigned to variables vrpro ={ a esn nm:'o feig, ae je lmn' gtu:'3be, ihb w3l' itrss ['ofecit,'ulm tx' 'oej'] neet: cfesrp' sbie et, nd.s }; vrmkAeoe=fnto (b){ a aewsm ucin oj ojaeoe=tu; b.wsm re }; vrgtae=fnto(b){ a eNm ucinoj rtr ojnm; eun b.ae } mkAeoepro) aewsm(esn; cnoelggtaepro); osl.o(eNm(esn)
  • 8. CONVERT TO COFFEESCRIPT Step 1: Remove v r a pro ={ esn nm:'o feig, ae je lmn' titr '3be, wte: w3l' gtu:'3be, ihb w3l' itrss ['ofecit,'ulm tx' 'oej'] neet: cfesrp' sbie et, nd.s }; mkAeoe=fnto (b){ aewsm ucin oj ojaeoe=tu; b.wsm re } gtae=fnto (b){ eNm ucin oj rtr ojnm; eun b.ae } mkAeoepro) aewsm(esn; cnoelggtaepro); osl.o(eNm(esn)
  • 9. CONVERT TO COFFEESCRIPT Step 2: change f n t o syntax & remove brackets ucin pro ={ esn nm:'o feig, ae je lmn' titr '3be, wte: w3l' gtu:'3be, ihb w3l' itrss ['ofecit,'ulm tx' 'oej'] neet: cfesrp' sbie et, nd.s }; mkAeoe=(b)-g; aewsm oj &t ojaeoe=tu; b.wsm re gtae=(b)-g; eNm oj &t rtr ojnm; eun b.ae mkAeoepro) aewsm(esn; cnoelggtaepro); osl.o(eNm(esn) This compiles! But why stop here?
  • 10. CONVERT TO COFFEESCRIPT Remove some ugly bits; brackets and semi-colons pro = esn nm:'o feig, ae je lmn' titr '3be, wte: w3l' gtu:'3be, ihb w3l' itrss ['ofecit,'ulm tx' 'oej'] neet: cfesrp' sbie et, nd.s mkAeoe=(b)-g; aewsm oj &t ojaeoe=tu b.wsm re gtae=(b)-g; eNm oj &t rtr ojnm eun b.ae mkAeoepro) aewsm(esn cnoelggtaepro) osl.o(eNm(esn)
  • 11. CONVERT TO COFFEESCRIPT Remove parens, commas and returns pro = esn nm:'o feig ae je lmn' titr '3be wte: w3l' gtu:'3be ihb w3l' itrss ['ofecit,'ulm tx' 'oej'] neet: cfesrp' sbie et, nd.s mkAeoe=(b)-g; aewsm oj &t ojaeoe=tu b.wsm re gtae=(b)-g; eNm oj &t ojnm b.ae mkAeoepro aewsm esn cnoelggtaepro osl.o eNm esn Aw yeah!
  • 13. READS LIKE ENGLISH atetctd=tu uls acuti fle uhniae re nes con s as i nmi 1 f u s 3 aet"inr" lr wne! wne =tu i pc i [1,3,8 ] inr re f ik n 2 7 8
  • 14. EASY TO UNDERSTAND us SHORTCUTS nm =[.1] 1.0 aet"yfvrt nme i #nm[]" lr M aoie ubr s {us3} casPro ls esn cntutr (nm)- osrco: @ae > gtae - eNm: > @ae nm
  • 15. CLEAN SYNTAX Well formatted code Easier to read Easier to maintain Less typing, less errors Fun to write
  • 16. MY FAVORITE SUGAR BLOCK STRINGS & INTERPOLATION
  • 17. MY FAVORITE SUGAR FUNCTION BINDING AKA "FAT ARROW"
  • 18. MY FAVORITE SUGAR THE EXISTENTIAL OPERATOR
  • 19. MY FAVORITE SUGAR CLASS SYNTAX
  • 20. ECMASCRIPT 6 WITHOUT THE WAIT Still generates ES5 code Works like an ES6 shim
  • 21. MANY "WEIRD" PARTS ARE OPTIONAL Omitting r t r eun Using i , i n to , a detc s s o, r n, Removing commas in arrays Removing commas and brackets in objects Dropping parens on function calls
  • 22. LET'S SEE SOME EXAMPLES
  • 24.
  • 26. CLASS INHERITANCE Coffeescript.org ES6 style class inheritance Makes s p rvery easy to use ue Simpler class Class like you're probably used to No b n or e t n required id xed Fair JS version Creates b n and e t n smethods id xed Still calls s p r ue Whole lotta mess
  • 27. COFFEESCRIPT IS GREAT NO DOWNSIDES TO USING IT
  • 28. ANOTHER SYNTAX TO LEARN Not pure JS Could complicate hiring/consulting Pretty easy if you know JS Maybe you should hire better
  • 29. REQUIRES COMPILING (MOST OF THE TIME) Adds another step to development and deployment Build process: c f e , grunt, make/jake, etc ofe Asset pipeline: connect-assets Runtimes: n d - e oedv Hosting: heroku, nodester, nodejitsu
  • 30. DEBUGGING Compiled into javascript Runtime errors reference js code Editor plugins ease this
  • 31. DON'T STOP WITH JAVASCRIPT
  • 32. HTML Haml pretty much started it Slim made it cleaner Jade brought it to JS Coffeekup coffeescript as markup
  • 33. JADE Full template library Variables, conditionals, inheritance, etc Client-side or server-side
  • 34. CSS Sass /SCSS/Sassy CSS started this Less made it universal Stylus brought it to JS
  • 35. STYLUS Variables, mixins, calculations, conditionals Everything is optional (except the whitespace) Mix and match freely
  • 36. THANKS! joe fleming twitter: @w33ble | github: w33ble