SlideShare a Scribd company logo
1 of 26
End-to-End
  CoffeeScript
Presented by Trevor Burnham
     at RailsConf 2011
Part I
CoffeeScript!?!?
What is CoffeeScript?
Do you have to use it?
But seriously...
Things I’ll cover today:

A brief primer on the CoffeeScript language
How it works with the Rails 3.1 asset
pipeline
Running the same JS/CS code on both the
client and the server
And things I won’t:

The CoffeeScript language in depth (that
would take a whole book... available at
http://coffeescript-book.com)
Sprockets 2 (#=
require
foo)

jQuery UJS ($.rails)
CoffeeScript crash course



 “Dash rocket” instead of function

 Semantic whitespace instead of {}

 Implicit parentheses, implicit var scoping
Awesome goodies for
      Rubyists


Postx if/unless

Implicit returns

String interpolations
Things that feel weird to
        Rubyists



Parentheses are not optional on functions
with no arguments
It’s just JavaScript™
Things that feel weird to
     JavaScripters


CoffeeScript’s of is JavaScript’s in

CoffeeScript’s in is Python’s in

CoffeeScript’s == is JavaScript’s ===
Tradeoffs

Debugging (will get better, but currently
kind of a pain)
Changing versions (though it’s been
pretty stable for the last 5 months)
Less documentation (but there is a
book from PragProg...)
Even so!

After only a week of using CoffeeScript,
I felt more productive than I ever had in
JavaScript.
The community is awesome.
Learning CoffeeScript might make you think
more deeply about JavaScript.
Part II
CoffeeScript in Rails 3.1
Let’s make a Rails app!

rails
new
EndToEnd
cd
EndToEnd
rails
generate
controller
User
signup

Clone the repo if you want to follow along...
http://github.com/TrevorBurnham/EndToEnd)
JavaScripts are assets
New in Rails 3.1, generate
controller gives
us a CoffeeScript le automatically:
Compound extensions

.html.erb & .html.haml → HTML

.css.scss & .css.sass → CSS

.js.coffee → JavaScript

Want to use a different format? Just rename!
application.js → application.js.coffee
Compound extensions
Stylesheets and JavaScripts are automatically
concatenated by Sprockets 2, even in development:




All the CSS and JS is loaded on every page, so it’s
still up to you to isolate controller-specic
functionality.
Building a sign-up box
Adding JS validations
Great, but...
Client-side validations are just there to
provide a friendlier user experience. What
really matters are server-side validations.
Traditionally, we’d do this by using
ActiveRecord, repeating much of the work
we just did...
But there’s another way!
Server-side JavaScript!
  (And CoffeeScript)
If you’ve got coffee‐script in your
Gemfile, then you’ve already got ExecJS:
https://github.com/sstephenson/execjs
It uses the best available JS environment on
your system. Use therubyracer (or
therubyracer‐heroku) for maximum
portability.
No need to rewrite the
 same validation code!
ExecJS lets us turn our CoffeeScript
validation code into a Ruby object:
A small taste of
       what’s to come
Future plugins will make the server-side JS
process smoother in Rails
With jsdom, you can do practically anything
that you could do with client-side JS
(including manipulating HTML with jQuery!)
Validation, templating... anything you’re
duplicating can be done as end-to-end JS.
How can you become a
  CoffeeScript ninja?
Ofcial site, great overview:
http://coffeescript.org
Nice screencast:
http://peepcode.com/products/coffeescript
Totally unbiased book recommendation:
http://coffeescript-book.com
Thanks
        Questions?
trevorburnham@gmail.com

More Related Content

What's hot

Lessons Learnt in 2009
Lessons Learnt in 2009Lessons Learnt in 2009
Lessons Learnt in 2009pratiknaik
 
Ruby On Rails Introduction
Ruby On Rails IntroductionRuby On Rails Introduction
Ruby On Rails IntroductionThomas Fuchs
 
DSLs Internas e Ruby
DSLs Internas e RubyDSLs Internas e Ruby
DSLs Internas e RubyFabio Kung
 
Introduce cucumber
Introduce cucumberIntroduce cucumber
Introduce cucumberBachue Zhou
 
Drupal + selenium
Drupal + seleniumDrupal + selenium
Drupal + seleniumhernanibf
 
JSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic AppsJSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic AppsSpike Brehm
 
Bundler is the Best
Bundler is the BestBundler is the Best
Bundler is the Bestdead_arm
 
The Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web appsThe Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web appsJohn Anderson
 
Isomorphic App Development with Ruby and Volt - Rubyconf2014
Isomorphic App Development with Ruby and Volt - Rubyconf2014Isomorphic App Development with Ruby and Volt - Rubyconf2014
Isomorphic App Development with Ruby and Volt - Rubyconf2014ryanstout
 
The Asynchronous Pattern (for beginners)
The Asynchronous Pattern (for beginners)The Asynchronous Pattern (for beginners)
The Asynchronous Pattern (for beginners)Andrea Tino
 
Let's talk ChatOps - Hubot with less CoffeeScript
Let's talk ChatOps - Hubot with less CoffeeScriptLet's talk ChatOps - Hubot with less CoffeeScript
Let's talk ChatOps - Hubot with less CoffeeScriptSarahKowalik
 
Puppet at Pinterest
Puppet at PinterestPuppet at Pinterest
Puppet at PinterestPuppet
 
Concurrent Ruby Application Servers
Concurrent Ruby Application ServersConcurrent Ruby Application Servers
Concurrent Ruby Application ServersLin Jen-Shin
 
Vidoop CouchDB Talk
Vidoop CouchDB TalkVidoop CouchDB Talk
Vidoop CouchDB TalkChris Anderson
 
Volt 2015
Volt 2015Volt 2015
Volt 2015ryanstout
 
Deploying a Location-Aware Ember Application
Deploying a Location-Aware Ember ApplicationDeploying a Location-Aware Ember Application
Deploying a Location-Aware Ember ApplicationBen Limmer
 
TechDays - IronRuby
TechDays - IronRubyTechDays - IronRuby
TechDays - IronRubyBen Hall
 

What's hot (20)

Lessons Learnt in 2009
Lessons Learnt in 2009Lessons Learnt in 2009
Lessons Learnt in 2009
 
Ruby On Rails Introduction
Ruby On Rails IntroductionRuby On Rails Introduction
Ruby On Rails Introduction
 
DSLs Internas e Ruby
DSLs Internas e RubyDSLs Internas e Ruby
DSLs Internas e Ruby
 
Introduce cucumber
Introduce cucumberIntroduce cucumber
Introduce cucumber
 
Drupal + selenium
Drupal + seleniumDrupal + selenium
Drupal + selenium
 
node.js - Fast event based web application development
node.js - Fast event based web application developmentnode.js - Fast event based web application development
node.js - Fast event based web application development
 
JSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic AppsJSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic Apps
 
Bundler is the Best
Bundler is the BestBundler is the Best
Bundler is the Best
 
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
 
Ansible 202 - sysarmy
Ansible 202 - sysarmyAnsible 202 - sysarmy
Ansible 202 - sysarmy
 
The Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web appsThe Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web apps
 
Isomorphic App Development with Ruby and Volt - Rubyconf2014
Isomorphic App Development with Ruby and Volt - Rubyconf2014Isomorphic App Development with Ruby and Volt - Rubyconf2014
Isomorphic App Development with Ruby and Volt - Rubyconf2014
 
The Asynchronous Pattern (for beginners)
The Asynchronous Pattern (for beginners)The Asynchronous Pattern (for beginners)
The Asynchronous Pattern (for beginners)
 
Let's talk ChatOps - Hubot with less CoffeeScript
Let's talk ChatOps - Hubot with less CoffeeScriptLet's talk ChatOps - Hubot with less CoffeeScript
Let's talk ChatOps - Hubot with less CoffeeScript
 
Puppet at Pinterest
Puppet at PinterestPuppet at Pinterest
Puppet at Pinterest
 
Concurrent Ruby Application Servers
Concurrent Ruby Application ServersConcurrent Ruby Application Servers
Concurrent Ruby Application Servers
 
Vidoop CouchDB Talk
Vidoop CouchDB TalkVidoop CouchDB Talk
Vidoop CouchDB Talk
 
Volt 2015
Volt 2015Volt 2015
Volt 2015
 
Deploying a Location-Aware Ember Application
Deploying a Location-Aware Ember ApplicationDeploying a Location-Aware Ember Application
Deploying a Location-Aware Ember Application
 
TechDays - IronRuby
TechDays - IronRubyTechDays - IronRuby
TechDays - IronRuby
 

Viewers also liked

E field disk
E field diskE field disk
E field diskFFMdeMul
 
Cubmaster's Toolbox
Cubmaster's ToolboxCubmaster's Toolbox
Cubmaster's ToolboxJohn DeGroote
 
Nz Marine Cluster May 12 Report
Nz Marine Cluster May 12 ReportNz Marine Cluster May 12 Report
Nz Marine Cluster May 12 ReportBen Mayson
 
The CoffeeScript Edge
The CoffeeScript EdgeThe CoffeeScript Edge
The CoffeeScript EdgeTrevorBurnham
 
Magazine Evaluation
Magazine EvaluationMagazine Evaluation
Magazine Evaluationsophiesharkey
 
2013 10-22 internet-arriskuak_andramendi_eu
2013 10-22 internet-arriskuak_andramendi_eu2013 10-22 internet-arriskuak_andramendi_eu
2013 10-22 internet-arriskuak_andramendi_euUrko Zurutuza
 
Internet-en, ze irudi ari naiz ematen?
Internet-en, ze irudi ari naiz ematen?Internet-en, ze irudi ari naiz ematen?
Internet-en, ze irudi ari naiz ematen?Urko Zurutuza
 
'Decisions For Life' -Project
'Decisions For Life' -Project'Decisions For Life' -Project
'Decisions For Life' -Projectwageindicator
 
Nz Marine Cluster May 12 Ppt
Nz Marine Cluster May 12 PptNz Marine Cluster May 12 Ppt
Nz Marine Cluster May 12 PptBen Mayson
 
Magazine Evaluation
Magazine EvaluationMagazine Evaluation
Magazine Evaluationsophiesharkey
 
Case Studies In Stroke Prepared By Arlyn M. Valencia, M.D.
Case Studies In Stroke Prepared By Arlyn M. Valencia, M.D.Case Studies In Stroke Prepared By Arlyn M. Valencia, M.D.
Case Studies In Stroke Prepared By Arlyn M. Valencia, M.D.guestc179d8
 
Sane Async Patterns
Sane Async PatternsSane Async Patterns
Sane Async PatternsTrevorBurnham
 
Cerebral Hemorrhage By Arlyn M. Valencia, M.D. Associate Professor, Universit...
Cerebral Hemorrhage By Arlyn M. Valencia, M.D. Associate Professor, Universit...Cerebral Hemorrhage By Arlyn M. Valencia, M.D. Associate Professor, Universit...
Cerebral Hemorrhage By Arlyn M. Valencia, M.D. Associate Professor, Universit...guestc179d8
 
Case Studies In Stroke
Case Studies In StrokeCase Studies In Stroke
Case Studies In Strokeguestc179d8
 
Internet arriskuak bidegoian_2011-09-22
Internet arriskuak bidegoian_2011-09-22Internet arriskuak bidegoian_2011-09-22
Internet arriskuak bidegoian_2011-09-22Urko Zurutuza
 
TOP 121 TWEETS ON HOW TO PREACH BETTER @therocketco #preachrocket
TOP 121 TWEETS ON HOW TO PREACH BETTER @therocketco #preachrocketTOP 121 TWEETS ON HOW TO PREACH BETTER @therocketco #preachrocket
TOP 121 TWEETS ON HOW TO PREACH BETTER @therocketco #preachrocketEmpowered Presentations
 
El tiempo
El tiempoEl tiempo
El tiempoJuan Diaz
 

Viewers also liked (20)

E field disk
E field diskE field disk
E field disk
 
Cubmaster's Toolbox
Cubmaster's ToolboxCubmaster's Toolbox
Cubmaster's Toolbox
 
Nz Marine Cluster May 12 Report
Nz Marine Cluster May 12 ReportNz Marine Cluster May 12 Report
Nz Marine Cluster May 12 Report
 
Presentation1
Presentation1Presentation1
Presentation1
 
Presentation1
Presentation1Presentation1
Presentation1
 
The CoffeeScript Edge
The CoffeeScript EdgeThe CoffeeScript Edge
The CoffeeScript Edge
 
Magazine Evaluation
Magazine EvaluationMagazine Evaluation
Magazine Evaluation
 
2013 10-22 internet-arriskuak_andramendi_eu
2013 10-22 internet-arriskuak_andramendi_eu2013 10-22 internet-arriskuak_andramendi_eu
2013 10-22 internet-arriskuak_andramendi_eu
 
Internet-en, ze irudi ari naiz ematen?
Internet-en, ze irudi ari naiz ematen?Internet-en, ze irudi ari naiz ematen?
Internet-en, ze irudi ari naiz ematen?
 
'Decisions For Life' -Project
'Decisions For Life' -Project'Decisions For Life' -Project
'Decisions For Life' -Project
 
Nz Marine Cluster May 12 Ppt
Nz Marine Cluster May 12 PptNz Marine Cluster May 12 Ppt
Nz Marine Cluster May 12 Ppt
 
Magazine Evaluation
Magazine EvaluationMagazine Evaluation
Magazine Evaluation
 
Case Studies In Stroke Prepared By Arlyn M. Valencia, M.D.
Case Studies In Stroke Prepared By Arlyn M. Valencia, M.D.Case Studies In Stroke Prepared By Arlyn M. Valencia, M.D.
Case Studies In Stroke Prepared By Arlyn M. Valencia, M.D.
 
Sane Async Patterns
Sane Async PatternsSane Async Patterns
Sane Async Patterns
 
Cerebral Hemorrhage By Arlyn M. Valencia, M.D. Associate Professor, Universit...
Cerebral Hemorrhage By Arlyn M. Valencia, M.D. Associate Professor, Universit...Cerebral Hemorrhage By Arlyn M. Valencia, M.D. Associate Professor, Universit...
Cerebral Hemorrhage By Arlyn M. Valencia, M.D. Associate Professor, Universit...
 
Case Studies In Stroke
Case Studies In StrokeCase Studies In Stroke
Case Studies In Stroke
 
Internet arriskuak bidegoian_2011-09-22
Internet arriskuak bidegoian_2011-09-22Internet arriskuak bidegoian_2011-09-22
Internet arriskuak bidegoian_2011-09-22
 
Things Dogs Carry #THINGSICARRY
Things Dogs Carry #THINGSICARRYThings Dogs Carry #THINGSICARRY
Things Dogs Carry #THINGSICARRY
 
TOP 121 TWEETS ON HOW TO PREACH BETTER @therocketco #preachrocket
TOP 121 TWEETS ON HOW TO PREACH BETTER @therocketco #preachrocketTOP 121 TWEETS ON HOW TO PREACH BETTER @therocketco #preachrocket
TOP 121 TWEETS ON HOW TO PREACH BETTER @therocketco #preachrocket
 
El tiempo
El tiempoEl tiempo
El tiempo
 

Similar to End to-End CoffeeScript

Writing Bullet-Proof Javascript: By Using CoffeeScript
Writing Bullet-Proof Javascript: By Using CoffeeScriptWriting Bullet-Proof Javascript: By Using CoffeeScript
Writing Bullet-Proof Javascript: By Using CoffeeScriptSusan Potter
 
CoffeeScript the Awesome
CoffeeScript the AwesomeCoffeeScript the Awesome
CoffeeScript the AwesomeJames Hughes
 
Coffee scripts with rails
Coffee scripts with railsCoffee scripts with rails
Coffee scripts with railsDevilal Dheer
 
Coffeescript unfancy javascript
Coffeescript unfancy javascriptCoffeescript unfancy javascript
Coffeescript unfancy javascriptDimitris Tsironis
 
Concurrency in ruby
Concurrency in rubyConcurrency in ruby
Concurrency in rubyMarco Borromeo
 
CoffeeScript - TechTalk 21/10/2013
CoffeeScript - TechTalk 21/10/2013CoffeeScript - TechTalk 21/10/2013
CoffeeScript - TechTalk 21/10/2013Spyros Ioakeimidis
 
Coffee script throwdown
Coffee script throwdownCoffee script throwdown
Coffee script throwdownNicholas McClay
 
Front-End Engineering 101
Front-End Engineering 101Front-End Engineering 101
Front-End Engineering 101Milan Korsos
 
TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011Lance Ball
 
One does not simply "Upgrade to Rails 3"
One does not simply "Upgrade to Rails 3"One does not simply "Upgrade to Rails 3"
One does not simply "Upgrade to Rails 3"testflyjets
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...Paul Jensen
 
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar BatsovRuby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar BatsovMichael Kimathi
 
React js basics
React js basicsReact js basics
React js basicsMaulik Shah
 
appborg, coffeesurgeon, moof, logging-system
appborg, coffeesurgeon, moof, logging-systemappborg, coffeesurgeon, moof, logging-system
appborg, coffeesurgeon, moof, logging-systemendian7000
 
Rails 3.1
Rails 3.1Rails 3.1
Rails 3.1Lori Olson
 
CoffeeScript: The Good Parts
CoffeeScript: The Good PartsCoffeeScript: The Good Parts
CoffeeScript: The Good PartsC4Media
 

Similar to End to-End CoffeeScript (20)

Writing Bullet-Proof Javascript: By Using CoffeeScript
Writing Bullet-Proof Javascript: By Using CoffeeScriptWriting Bullet-Proof Javascript: By Using CoffeeScript
Writing Bullet-Proof Javascript: By Using CoffeeScript
 
CoffeeScript the Awesome
CoffeeScript the AwesomeCoffeeScript the Awesome
CoffeeScript the Awesome
 
Coffee scripts with rails
Coffee scripts with railsCoffee scripts with rails
Coffee scripts with rails
 
Smooth CoffeeScript
Smooth CoffeeScriptSmooth CoffeeScript
Smooth CoffeeScript
 
Overview of CoffeeScript
Overview of CoffeeScriptOverview of CoffeeScript
Overview of CoffeeScript
 
Coffeescript unfancy javascript
Coffeescript unfancy javascriptCoffeescript unfancy javascript
Coffeescript unfancy javascript
 
Concurrency in ruby
Concurrency in rubyConcurrency in ruby
Concurrency in ruby
 
CoffeeScript - TechTalk 21/10/2013
CoffeeScript - TechTalk 21/10/2013CoffeeScript - TechTalk 21/10/2013
CoffeeScript - TechTalk 21/10/2013
 
Coffee script throwdown
Coffee script throwdownCoffee script throwdown
Coffee script throwdown
 
Front-End Engineering 101
Front-End Engineering 101Front-End Engineering 101
Front-End Engineering 101
 
TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011
 
One does not simply "Upgrade to Rails 3"
One does not simply "Upgrade to Rails 3"One does not simply "Upgrade to Rails 3"
One does not simply "Upgrade to Rails 3"
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
 
TorqueBox
TorqueBoxTorqueBox
TorqueBox
 
Where is my scalable API?
Where is my scalable API?Where is my scalable API?
Where is my scalable API?
 
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar BatsovRuby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
 
React js basics
React js basicsReact js basics
React js basics
 
appborg, coffeesurgeon, moof, logging-system
appborg, coffeesurgeon, moof, logging-systemappborg, coffeesurgeon, moof, logging-system
appborg, coffeesurgeon, moof, logging-system
 
Rails 3.1
Rails 3.1Rails 3.1
Rails 3.1
 
CoffeeScript: The Good Parts
CoffeeScript: The Good PartsCoffeeScript: The Good Parts
CoffeeScript: The Good Parts
 

Recently uploaded

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 

Recently uploaded (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 

End to-End CoffeeScript

  • 1. End-to-End CoffeeScript Presented by Trevor Burnham at RailsConf 2011
  • 4. Do you have to use it?
  • 6. Things I’ll cover today: A brief primer on the CoffeeScript language How it works with the Rails 3.1 asset pipeline Running the same JS/CS code on both the client and the server
  • 7. And things I won’t: The CoffeeScript language in depth (that would take a whole book... available at http://coffeescript-book.com) Sprockets 2 (#=
require
foo) jQuery UJS ($.rails)
  • 8. CoffeeScript crash course “Dash rocket” instead of function Semantic whitespace instead of {} Implicit parentheses, implicit var scoping
  • 9. Awesome goodies for Rubyists Postx if/unless Implicit returns String interpolations
  • 10. Things that feel weird to Rubyists Parentheses are not optional on functions with no arguments It’s just JavaScript™
  • 11. Things that feel weird to JavaScripters CoffeeScript’s of is JavaScript’s in CoffeeScript’s in is Python’s in CoffeeScript’s == is JavaScript’s ===
  • 12. Tradeoffs Debugging (will get better, but currently kind of a pain) Changing versions (though it’s been pretty stable for the last 5 months) Less documentation (but there is a book from PragProg...)
  • 13. Even so! After only a week of using CoffeeScript, I felt more productive than I ever had in JavaScript. The community is awesome. Learning CoffeeScript might make you think more deeply about JavaScript.
  • 15. Let’s make a Rails app! rails
new
EndToEnd cd
EndToEnd rails
generate
controller
User
signup Clone the repo if you want to follow along... http://github.com/TrevorBurnham/EndToEnd)
  • 16. JavaScripts are assets New in Rails 3.1, generate
controller gives us a CoffeeScript le automatically:
  • 17. Compound extensions .html.erb & .html.haml → HTML .css.scss & .css.sass → CSS .js.coffee → JavaScript Want to use a different format? Just rename! application.js → application.js.coffee
  • 18. Compound extensions Stylesheets and JavaScripts are automatically concatenated by Sprockets 2, even in development: All the CSS and JS is loaded on every page, so it’s still up to you to isolate controller-specic functionality.
  • 21. Great, but... Client-side validations are just there to provide a friendlier user experience. What really matters are server-side validations. Traditionally, we’d do this by using ActiveRecord, repeating much of the work we just did... But there’s another way!
  • 22. Server-side JavaScript! (And CoffeeScript) If you’ve got coffee‐script in your Gemle, then you’ve already got ExecJS: https://github.com/sstephenson/execjs It uses the best available JS environment on your system. Use therubyracer (or therubyracer‐heroku) for maximum portability.
  • 23. No need to rewrite the same validation code! ExecJS lets us turn our CoffeeScript validation code into a Ruby object:
  • 24. A small taste of what’s to come Future plugins will make the server-side JS process smoother in Rails With jsdom, you can do practically anything that you could do with client-side JS (including manipulating HTML with jQuery!) Validation, templating... anything you’re duplicating can be done as end-to-end JS.
  • 25. How can you become a CoffeeScript ninja? Ofcial site, great overview: http://coffeescript.org Nice screencast: http://peepcode.com/products/coffeescript Totally unbiased book recommendation: http://coffeescript-book.com
  • 26. Thanks Questions? trevorburnham@gmail.com