SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
10 razões para você
                    usar CoffeeScript
                            e se apaixonar...




                           Lukas Alexandre
Saturday, January 19, 13
1-Sintaxe limpa
                     • Inspirada em Ruby e Python;
                     • Parênteses opcionais;
                            message = 'Hello World'
                            sayHello message




Saturday, January 19, 13
2-Impõe boas práticas de JS
                  • Escopos fechados;
                  • Previne “global namespace flooding”;
                           sayHello = (message) ->   (function() {
                            console.log message
                                                      var sayHello;
                           sayHello 'Hello World'
                                                      sayHello = function(message) {
                                                       return console.log(message);
                                                      };

                                                      sayHello('Hello World');

                                                     }).call(this);




Saturday, January 19, 13
3-Fat Arrow
                     • Workarounds imbutidos;

                    coffee =                          var coffee = {
                     isFull: true                       isFull: true,
                     watchDrink: ->                     watchDrink: function(){
                       $('.drink a').on 'click', =>       var that = this;
                        @isFull = false                   $('.drink a').on('click', function(){
                                                           that.isFull = false;
                                                          });
                                                        }
                                                      }




Saturday, January 19, 13
4-Interpolação de strings
                     • Chega de + + + +

                   name = 'John Doe'                      var name = 'John Doe';
                   console.log "Hi, my name is #{name}"   console.log("Hi, my name is " + "name")




Saturday, January 19, 13
5-List Comprehensions

           names = ['Foo', 'Bar', 'Baz']         var names = ['Foo', 'Bar', 'Baz'];
           console.log(name) for name in names
                                                 for(var i=0; i < names.length; i++){
                                                   console.log(names[i]);
                                                 }




Saturday, January 19, 13
6-Modificadores Condicionais


                   allowEntrance() unless age < 21   if(age > 21) {
                   allowEntrance() if age >= 21        allowEntrance()
                                                     }
                                                     if(age >= 21) {
                                                       allowEntrance()
                                                     }




Saturday, January 19, 13
7-Classes
                           class Coffee

                            constructor: (@name) ->

                            brew: ->
                             console.log 'Brewing'

                            description: ->
                             console.log "Coffee is #{@name}"

                           frenchCoffee = new Coffee('French')
                           frenchCoffee.description # Coffee is French




Saturday, January 19, 13
8-Uma visão do futuro
                     • Suporte de Brendan Eich;
                     • @ e => no JS;




Saturday, January 19, 13
9-Aceitação da comunidade

                     • Rails >= 3.1;
                     • Python & PHP;
                     • Unit Testing frameworks;



Saturday, January 19, 13
10-Ótimas fontes de aprendizado

                     • http://coffeescript.org
                     • http://coffeescriptcookbook.com
                     • http://www.codeschool.com/courses/
                           coffeescript




Saturday, January 19, 13
Contato
                     • pessoal: lukasalexandre@me.com
                     • profissional: lukas@codelogic.me
                     • http://github.com/lukasalexandre



Saturday, January 19, 13
Perguntas?




Saturday, January 19, 13
Referências
                     • http://www.netmagazine.com/features/10-
                           good-reasons-use-coffeescript




Saturday, January 19, 13

Contenu connexe

Tendances

Python Workshop by Tom Frantz
Python Workshop by Tom FrantzPython Workshop by Tom Frantz
Python Workshop by Tom FrantzProttay Karim
 
He 74 a-thltht-lãxuântâm-11tlt
He 74 a-thltht-lãxuântâm-11tltHe 74 a-thltht-lãxuântâm-11tlt
He 74 a-thltht-lãxuântâm-11tltlaonap166
 
Fake your files - MemFs
Fake your files - MemFsFake your files - MemFs
Fake your files - MemFsSimon Courtois
 
ECMAScript 6 new features
ECMAScript 6 new featuresECMAScript 6 new features
ECMAScript 6 new featuresGephenSG
 
Introduction to Resque
Introduction to ResqueIntroduction to Resque
Introduction to Resquekoshigoe
 
Build a compiler in 2hrs - NCrafts Paris 2015
Build a compiler in 2hrs -  NCrafts Paris 2015Build a compiler in 2hrs -  NCrafts Paris 2015
Build a compiler in 2hrs - NCrafts Paris 2015Phillip Trelford
 

Tendances (7)

Python Workshop by Tom Frantz
Python Workshop by Tom FrantzPython Workshop by Tom Frantz
Python Workshop by Tom Frantz
 
He 74 a-thltht-lãxuântâm-11tlt
He 74 a-thltht-lãxuântâm-11tltHe 74 a-thltht-lãxuântâm-11tlt
He 74 a-thltht-lãxuântâm-11tlt
 
Fake your files - MemFs
Fake your files - MemFsFake your files - MemFs
Fake your files - MemFs
 
ECMAScript 6 new features
ECMAScript 6 new featuresECMAScript 6 new features
ECMAScript 6 new features
 
Introduction to Resque
Introduction to ResqueIntroduction to Resque
Introduction to Resque
 
Jsconf.us.2013
Jsconf.us.2013Jsconf.us.2013
Jsconf.us.2013
 
Build a compiler in 2hrs - NCrafts Paris 2015
Build a compiler in 2hrs -  NCrafts Paris 2015Build a compiler in 2hrs -  NCrafts Paris 2015
Build a compiler in 2hrs - NCrafts Paris 2015
 

En vedette

Authors part 2 foster 13
Authors part 2 foster 13Authors part 2 foster 13
Authors part 2 foster 13fosteraf
 
Introdução Ruby On Rails
Introdução Ruby On RailsIntrodução Ruby On Rails
Introdução Ruby On RailsLukas Alexandre
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionIn a Rocket
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanPost Planner
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting PersonalKirsty Hulse
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldabaux singapore
 

En vedette (7)

Authors part 2 foster 13
Authors part 2 foster 13Authors part 2 foster 13
Authors part 2 foster 13
 
Introdução Ruby On Rails
Introdução Ruby On RailsIntrodução Ruby On Rails
Introdução Ruby On Rails
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media Plan
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 

10 reasons to love CoffeeScript

  • 1. 10 razões para você usar CoffeeScript e se apaixonar... Lukas Alexandre Saturday, January 19, 13
  • 2. 1-Sintaxe limpa • Inspirada em Ruby e Python; • Parênteses opcionais; message = 'Hello World' sayHello message Saturday, January 19, 13
  • 3. 2-Impõe boas práticas de JS • Escopos fechados; • Previne “global namespace flooding”; sayHello = (message) -> (function() { console.log message var sayHello; sayHello 'Hello World' sayHello = function(message) { return console.log(message); }; sayHello('Hello World'); }).call(this); Saturday, January 19, 13
  • 4. 3-Fat Arrow • Workarounds imbutidos; coffee = var coffee = { isFull: true isFull: true, watchDrink: -> watchDrink: function(){ $('.drink a').on 'click', => var that = this; @isFull = false $('.drink a').on('click', function(){ that.isFull = false; }); } } Saturday, January 19, 13
  • 5. 4-Interpolação de strings • Chega de + + + + name = 'John Doe' var name = 'John Doe'; console.log "Hi, my name is #{name}" console.log("Hi, my name is " + "name") Saturday, January 19, 13
  • 6. 5-List Comprehensions names = ['Foo', 'Bar', 'Baz'] var names = ['Foo', 'Bar', 'Baz']; console.log(name) for name in names for(var i=0; i < names.length; i++){ console.log(names[i]); } Saturday, January 19, 13
  • 7. 6-Modificadores Condicionais allowEntrance() unless age < 21 if(age > 21) { allowEntrance() if age >= 21 allowEntrance() } if(age >= 21) { allowEntrance() } Saturday, January 19, 13
  • 8. 7-Classes class Coffee constructor: (@name) -> brew: -> console.log 'Brewing' description: -> console.log "Coffee is #{@name}" frenchCoffee = new Coffee('French') frenchCoffee.description # Coffee is French Saturday, January 19, 13
  • 9. 8-Uma visão do futuro • Suporte de Brendan Eich; • @ e => no JS; Saturday, January 19, 13
  • 10. 9-Aceitação da comunidade • Rails >= 3.1; • Python & PHP; • Unit Testing frameworks; Saturday, January 19, 13
  • 11. 10-Ótimas fontes de aprendizado • http://coffeescript.org • http://coffeescriptcookbook.com • http://www.codeschool.com/courses/ coffeescript Saturday, January 19, 13
  • 12. Contato • pessoal: lukasalexandre@me.com • profissional: lukas@codelogic.me • http://github.com/lukasalexandre Saturday, January 19, 13
  • 14. Referências • http://www.netmagazine.com/features/10- good-reasons-use-coffeescript Saturday, January 19, 13