SlideShare une entreprise Scribd logo
1  sur  53
• We love JavaScript
• We love Ruby better :)
Ruby + JavaScript
            No one trick pony

• We’ll see six specific uses in three
  categories
• All from the real world
• Examples use V8 interpreter (The Ruby
  Racer)
Embedding Javascript
     gem install therubyracer


                                Note that the only thing
                                available here is the js
                                standard objects
                                Nothing else except what
                                you explicitly embed into
                                it.

                                No DOM!
Embedding Javascript
     gem install therubyracer


                                Note that the only thing
                                available here is the js
                                standard objects
                                Nothing else except what
                                you explicitly embed into
                                it.

                                No DOM!
Embedding Javascript
     gem install therubyracer


                                Note that the only thing
                                available here is the js
                                standard objects
                                Nothing else except what
                                you explicitly embed into
                                it.

                                No DOM!
Embedding Javascript
     gem install therubyracer


                                Note that the only thing
                                available here is the js
                                standard objects
                                Nothing else except what
                                you explicitly embed into
                                it.

                                No DOM!
Embedding Javascript
     gem install therubyracer


                                Note that the only thing
                                available here is the js
                                standard objects
                                Nothing else except what
                                you explicitly embed into
                                it.

                                No DOM!
Simulated
Browser
1: Headless UA




• Full browser: sessions, redirects, and of
  course, javascript.
• Used to interact with Xbox Live website
2: Headless Unit Testing

• faster: no network/rendering overhead
• better test isolation
• easier to run on a CI server
now it gets interesting.




Code Sharing
3: Shared Templates
       The Problem

     Client(JavaScript)   Server(Ruby)
3: Shared Templates
             The Problem

           Client(JavaScript)
                 Client                     Server(Ruby)
                                               Server

       A



                     D



   B

                                HTML           Ta        Data


                                       Tb      Tc   Td
                     E

                                                    Te


   C
3: Shared Templates
                    The Problem
replace
                  Client(JavaScript)
                        Client                     Server(Ruby)
                                                      Server

              A



                            D



          B

                                       HTML           Ta        Data


                                              Tb      Tc   Td
                            E

                                                           Te


          C
Solution: Work the Server
                                    Client(JavaScript)
                                           Client                Server(Ruby)
                                                                   Server

                               A



                                                    D



                           B




                                                    E




                           C




                                                               you either make 2 ajax
                                                               requests
                                                               OR
                                                               you have a “wrapper”
                                                               html template
Still suboptimal because                                       which repurposes html
what if you need to use             DRY, but inefficient
                                                               as a data format for
that data for something
that has no template                Even so, sending fully
I.e. for a growl-like               assembled views across
notification.                        the wire, just feels
HTML is a terrible                  wrong. after all, aren’t
datastructure.                      we supposed to transmit
                                    just the model?
Solution: Work the Server
                                    Client(JavaScript)
                                           Client                                     Server(Ruby)
                                                                                        Server

                               A                                             AJAX for D



                                                    D                 HTML                Td        Data



                           B




                                                    E
                                                                             AJAX for C




                           C                                   HTML                       Tc        Data




                                                                                   you either make 2 ajax
                                                                                   requests
                                                                                   OR
                                                                                   you have a “wrapper”
                                                                                   html template
Still suboptimal because                                                           which repurposes html
what if you need to use             DRY, but inefficient
                                                                                   as a data format for
that data for something
that has no template                Even so, sending fully
I.e. for a growl-like               assembled views across
notification.                        the wire, just feels
HTML is a terrible                  wrong. after all, aren’t
datastructure.                      we supposed to transmit
                                    just the model?
Solution: Work the Server
                                    Client(JavaScript)
                                           Client                                           Server(Ruby)
                                                                                              Server

                               A                                                AJAX for D,C



                                                    D


                                                                 HT
                           B                                        ML


                                                                                       Td
                                                                                                     Data
                                                                         HTML
                                                                                       Tc
                                                    E
                                                             L
                                                          HTM



                           C




                                                                                       you either make 2 ajax
                                                                                       requests
                                                                                       OR
                                                                                       you have a “wrapper”
                                                                                       html template
Still suboptimal because                                                               which repurposes html
what if you need to use             DRY, but inefficient
                                                                                       as a data format for
that data for something
that has no template                Even so, sending fully
I.e. for a growl-like               assembled views across
notification.                        the wire, just feels
HTML is a terrible                  wrong. after all, aren’t
datastructure.                      we supposed to transmit
                                    just the model?
Solution: Bring the Templates With You

             Client(JavaScript)
                     Client                                     Server(Ruby)
                                                                  Server


         A                                       AJAX for D,C



                        D



     B




                        E




     C

                                       Ta                          Ta


                                  Tb   Tc   Td             Tb      Tc   Td


                                            Te                          Te
Solution: Bring the Templates With You

             Client(JavaScript)
                     Client                                                Server(Ruby)
                                                                             Server


         A                                                  AJAX for D,C



                        D
                                   HTM
                                         L

     B                                            Td

                                                                           Data

                                                  Tc

                               L
                        E   HTM




     C

                                             Ta                                   Ta


                                    Tb       Tc        Td             Tb          Tc   Td


                                                       Te                              Te
What this looks like in code.
What this looks like in code.
What this looks like in code.
Advantages

• Efficient, DRY
• Data is data. Display is display.
• Render without server when possible.
Advantages

• Efficient, DRY
• Data is data. Display is display.
• Render without server when possible.
• Share implementations, not abstractions
4: Shared DSL


• Implement a DSL in Javascript
• Use the same script on client and server
A JavaScript Customization Language
                                  Talk about requirement
                                  to edit in real time
A JavaScript Customization Language
                                  Talk about requirement
                                  to edit in real time
A JavaScript Customization Language
                                  Talk about requirement
                                  to edit in real time
A JavaScript Customization Language
                                  Talk about requirement
                                  to edit in real time
A JavaScript Customization Language

The client uses it to:

  • render the property browser and editors
  • edit and update values in real-time
The server uses it to:

  • lookup property names
  • set initial values
Delve a bit into the
        history of javascript




 Server
Extension
What makes JavaScript
    Awesome?
• Download completely and totally untrusted
  code from anywhere on the internet
• Execute it in your browser knowing that
  your OS, Data and CPU are (relatively) safe
  from attack.
• This has allowed for applications never
  thought possible.
Code from Anywhere
And here is Brendan
Eich’s great innovation                       Server
rendered here before
your very eyes




                          Client




                                              Server




                                   Awesome!



                                              Server
Code from Anywhere
And here is Brendan
Eich’s great innovation
rendered here before      Client
your very eyes



                                              Server




                          Client




                                   Awesome!




                          Client
rb eval() = danger!

         Explain why this is safe
         Explain why rb.eval() is
         dangerous
         Because it only has
         access to what you tell
         it.
rb eval() = danger!
js eval() = safe!
         Explain why this is safe
         Explain why rb.eval() is
         dangerous
         Because it only has
         access to what you tell
         it.
rb eval() = danger!
js eval() = safe!
         Explain why this is safe
         Explain why rb.eval() is
         dangerous
         Because it only has
         access to what you tell
         it.
rb eval() = danger!
js eval() = safe!
         Explain why this is safe
         Explain why rb.eval() is
         dangerous
         Because it only has
         access to what you tell
         it.
rb eval() = danger!
js eval() = safe!
         Explain why this is safe
         Explain why rb.eval() is
         dangerous
         Because it only has
         access to what you tell
         it.
5. Remote Control


• Run an agent written in Ruby
• Expose specific actions to clients
Process Control




            point out data format
            is whatever we want it
            to be, and can be
            extended to whatever we
            want.
Process Control




            point out data format
            is whatever we want it
            to be, and can be
            extended to whatever we
            want.
Process Control




            point out data format
            is whatever we want it
            to be, and can be
            extended to whatever we
            want.
Process Control




            point out data format
            is whatever we want it
            to be, and can be
            extended to whatever we
            want.
6: Canvatar    Script Store




                                javascript
         Image Store   image                 image++   Client




• Extend an image server at run time
• Use JavaScript to expose functionality
  implemented with RMagick or equivalent
Pimp My Avatar
Pimp My Avatar
1) fetch the image
Pimp My Avatar
1) fetch the image



              +
                     2) apply transform
Pimp My Avatar
1) fetch the image



              +                      =
                     2) apply transform
Ruby + JavaScript

• Ruby as browser implementation
• Ruby speaks JavaScript
• Ruby wrapped in JavaScript armor
• Let your imagination run wild      Use ruby as a the implementation
                                     language of the browser

                                     Make ruby smarter by making it
                                     speak the browser’s language
                                     natively

                                     Use JavaScripts
Thank You.

• cowboyd@thefrontside.net
• @cowboyd
• http://github.com/cowboyd/therubyracer
• http://github.com/cowboyd/therubyrhino
• http://drunkandretired.com/ThePodcast

Contenu connexe

Tendances

An Introduction to JavaScript
An Introduction to JavaScriptAn Introduction to JavaScript
An Introduction to JavaScripttonyh1
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)JiandSon
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101ygv2000
 
Introduction To Grails
Introduction To GrailsIntroduction To Grails
Introduction To GrailsEric Berry
 
Better DSL Support for Groovy-Eclipse
Better DSL Support for Groovy-EclipseBetter DSL Support for Groovy-Eclipse
Better DSL Support for Groovy-EclipseAndrew Eisenberg
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScriptJorg Janke
 
What Makes Objective C Dynamic?
What Makes Objective C Dynamic?What Makes Objective C Dynamic?
What Makes Objective C Dynamic?Kyle Oba
 
Java Multiple Choice Questions and Answers
Java Multiple Choice Questions and AnswersJava Multiple Choice Questions and Answers
Java Multiple Choice Questions and AnswersJava Projects
 
All about GWT
All about GWTAll about GWT
All about GWTEd Bras
 

Tendances (16)

Runtime
RuntimeRuntime
Runtime
 
Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
 
WEB TECHNOLOGIES JavaScript
WEB TECHNOLOGIES JavaScriptWEB TECHNOLOGIES JavaScript
WEB TECHNOLOGIES JavaScript
 
An Introduction to JavaScript
An Introduction to JavaScriptAn Introduction to JavaScript
An Introduction to JavaScript
 
Dart
DartDart
Dart
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
 
Introduction To Grails
Introduction To GrailsIntroduction To Grails
Introduction To Grails
 
Better DSL Support for Groovy-Eclipse
Better DSL Support for Groovy-EclipseBetter DSL Support for Groovy-Eclipse
Better DSL Support for Groovy-Eclipse
 
Lecture 5 javascript
Lecture 5 javascriptLecture 5 javascript
Lecture 5 javascript
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
Groovy & Grails
Groovy & GrailsGroovy & Grails
Groovy & Grails
 
Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
 
What Makes Objective C Dynamic?
What Makes Objective C Dynamic?What Makes Objective C Dynamic?
What Makes Objective C Dynamic?
 
Java Multiple Choice Questions and Answers
Java Multiple Choice Questions and AnswersJava Multiple Choice Questions and Answers
Java Multiple Choice Questions and Answers
 
All about GWT
All about GWTAll about GWT
All about GWT
 

Similaire à Ruby and JavaScript: 6 Ways They Work Together

Breaking the Server-Client Divide with Node.js and React
Breaking the Server-Client Divide with Node.js and ReactBreaking the Server-Client Divide with Node.js and React
Breaking the Server-Client Divide with Node.js and ReactDejan Glozic
 
aws lambda & api gateway
aws lambda & api gatewayaws lambda & api gateway
aws lambda & api gatewayfumihiko hata
 
JAX 2012: Moderne Architektur mit Spring und JavaScript
JAX 2012: Moderne Architektur mit Spring und JavaScriptJAX 2012: Moderne Architektur mit Spring und JavaScript
JAX 2012: Moderne Architektur mit Spring und JavaScriptmartinlippert
 
Modern Architectures with Spring and JavaScript
Modern Architectures with Spring and JavaScriptModern Architectures with Spring and JavaScript
Modern Architectures with Spring and JavaScriptmartinlippert
 
When Javascript isn't Javascript
When Javascript isn't Javascript When Javascript isn't Javascript
When Javascript isn't Javascript Tristan Gomez
 
Hummingbird - Open Source for Small Satellites - GSAW 2012
Hummingbird - Open Source for Small Satellites - GSAW 2012Hummingbird - Open Source for Small Satellites - GSAW 2012
Hummingbird - Open Source for Small Satellites - GSAW 2012Logica_hummingbird
 
The Ruby Racer: under the hood
The Ruby Racer: under the hoodThe Ruby Racer: under the hood
The Ruby Racer: under the hoodcowboyd
 
JavaScript Topic Maps in server environments
JavaScript Topic Maps in server environmentsJavaScript Topic Maps in server environments
JavaScript Topic Maps in server environmentstmra
 
JavaScript Topic Maps in server environments
JavaScript Topic Maps in server environmentsJavaScript Topic Maps in server environments
JavaScript Topic Maps in server environmentsJan Schreiber
 
GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011Manuel Carrasco Moñino
 
Drupal 6 JavaScript and jQuery
Drupal 6 JavaScript and jQueryDrupal 6 JavaScript and jQuery
Drupal 6 JavaScript and jQueryMatt Butcher
 
Modern Architectures with Spring and JavaScript
Modern Architectures with Spring and JavaScriptModern Architectures with Spring and JavaScript
Modern Architectures with Spring and JavaScriptmartinlippert
 
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5David Voyles
 
Kann JavaScript elegant sein?
Kann JavaScript elegant sein?Kann JavaScript elegant sein?
Kann JavaScript elegant sein?jbandi
 
Cloud Foundry Demo SD Forum Cloud Sig Feb09
Cloud Foundry Demo SD Forum Cloud Sig Feb09Cloud Foundry Demo SD Forum Cloud Sig Feb09
Cloud Foundry Demo SD Forum Cloud Sig Feb09Chris Richardson
 
Node.js #digpen presentation
Node.js #digpen presentationNode.js #digpen presentation
Node.js #digpen presentationGOSS Interactive
 
Server-Side JavaScript with jQuery and AOLserver
Server-Side JavaScript with jQuery and AOLserverServer-Side JavaScript with jQuery and AOLserver
Server-Side JavaScript with jQuery and AOLserverDossy Shiobara
 
Whats Ajax Cheatsheet
Whats Ajax CheatsheetWhats Ajax Cheatsheet
Whats Ajax Cheatsheet51 lecture
 

Similaire à Ruby and JavaScript: 6 Ways They Work Together (20)

Breaking the Server-Client Divide with Node.js and React
Breaking the Server-Client Divide with Node.js and ReactBreaking the Server-Client Divide with Node.js and React
Breaking the Server-Client Divide with Node.js and React
 
aws lambda & api gateway
aws lambda & api gatewayaws lambda & api gateway
aws lambda & api gateway
 
JAX 2012: Moderne Architektur mit Spring und JavaScript
JAX 2012: Moderne Architektur mit Spring und JavaScriptJAX 2012: Moderne Architektur mit Spring und JavaScript
JAX 2012: Moderne Architektur mit Spring und JavaScript
 
Modern Architectures with Spring and JavaScript
Modern Architectures with Spring and JavaScriptModern Architectures with Spring and JavaScript
Modern Architectures with Spring and JavaScript
 
When Javascript isn't Javascript
When Javascript isn't Javascript When Javascript isn't Javascript
When Javascript isn't Javascript
 
Hummingbird - Open Source for Small Satellites - GSAW 2012
Hummingbird - Open Source for Small Satellites - GSAW 2012Hummingbird - Open Source for Small Satellites - GSAW 2012
Hummingbird - Open Source for Small Satellites - GSAW 2012
 
The Ruby Racer: under the hood
The Ruby Racer: under the hoodThe Ruby Racer: under the hood
The Ruby Racer: under the hood
 
JavaScript Topic Maps in server environments
JavaScript Topic Maps in server environmentsJavaScript Topic Maps in server environments
JavaScript Topic Maps in server environments
 
JavaScript Topic Maps in server environments
JavaScript Topic Maps in server environmentsJavaScript Topic Maps in server environments
JavaScript Topic Maps in server environments
 
GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011
 
Node js with steroids
Node js with steroidsNode js with steroids
Node js with steroids
 
Drupal 6 JavaScript and jQuery
Drupal 6 JavaScript and jQueryDrupal 6 JavaScript and jQuery
Drupal 6 JavaScript and jQuery
 
Modern Architectures with Spring and JavaScript
Modern Architectures with Spring and JavaScriptModern Architectures with Spring and JavaScript
Modern Architectures with Spring and JavaScript
 
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
 
Kann JavaScript elegant sein?
Kann JavaScript elegant sein?Kann JavaScript elegant sein?
Kann JavaScript elegant sein?
 
Cloud Foundry Demo SD Forum Cloud Sig Feb09
Cloud Foundry Demo SD Forum Cloud Sig Feb09Cloud Foundry Demo SD Forum Cloud Sig Feb09
Cloud Foundry Demo SD Forum Cloud Sig Feb09
 
Node.js #digpen presentation
Node.js #digpen presentationNode.js #digpen presentation
Node.js #digpen presentation
 
Server-Side JavaScript with jQuery and AOLserver
Server-Side JavaScript with jQuery and AOLserverServer-Side JavaScript with jQuery and AOLserver
Server-Side JavaScript with jQuery and AOLserver
 
Whats Ajax Cheatsheet
Whats Ajax CheatsheetWhats Ajax Cheatsheet
Whats Ajax Cheatsheet
 
Slide Test
Slide TestSlide Test
Slide Test
 

Dernier

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
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
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Dernier (20)

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
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)
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
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
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

Ruby and JavaScript: 6 Ways They Work Together

  • 1.
  • 2. • We love JavaScript • We love Ruby better :)
  • 3. Ruby + JavaScript No one trick pony • We’ll see six specific uses in three categories • All from the real world • Examples use V8 interpreter (The Ruby Racer)
  • 4. Embedding Javascript gem install therubyracer Note that the only thing available here is the js standard objects Nothing else except what you explicitly embed into it. No DOM!
  • 5. Embedding Javascript gem install therubyracer Note that the only thing available here is the js standard objects Nothing else except what you explicitly embed into it. No DOM!
  • 6. Embedding Javascript gem install therubyracer Note that the only thing available here is the js standard objects Nothing else except what you explicitly embed into it. No DOM!
  • 7. Embedding Javascript gem install therubyracer Note that the only thing available here is the js standard objects Nothing else except what you explicitly embed into it. No DOM!
  • 8. Embedding Javascript gem install therubyracer Note that the only thing available here is the js standard objects Nothing else except what you explicitly embed into it. No DOM!
  • 10. 1: Headless UA • Full browser: sessions, redirects, and of course, javascript. • Used to interact with Xbox Live website
  • 11. 2: Headless Unit Testing • faster: no network/rendering overhead • better test isolation • easier to run on a CI server
  • 12. now it gets interesting. Code Sharing
  • 13. 3: Shared Templates The Problem Client(JavaScript) Server(Ruby)
  • 14. 3: Shared Templates The Problem Client(JavaScript) Client Server(Ruby) Server A D B HTML Ta Data Tb Tc Td E Te C
  • 15. 3: Shared Templates The Problem replace Client(JavaScript) Client Server(Ruby) Server A D B HTML Ta Data Tb Tc Td E Te C
  • 16. Solution: Work the Server Client(JavaScript) Client Server(Ruby) Server A D B E C you either make 2 ajax requests OR you have a “wrapper” html template Still suboptimal because which repurposes html what if you need to use DRY, but inefficient as a data format for that data for something that has no template Even so, sending fully I.e. for a growl-like assembled views across notification. the wire, just feels HTML is a terrible wrong. after all, aren’t datastructure. we supposed to transmit just the model?
  • 17. Solution: Work the Server Client(JavaScript) Client Server(Ruby) Server A AJAX for D D HTML Td Data B E AJAX for C C HTML Tc Data you either make 2 ajax requests OR you have a “wrapper” html template Still suboptimal because which repurposes html what if you need to use DRY, but inefficient as a data format for that data for something that has no template Even so, sending fully I.e. for a growl-like assembled views across notification. the wire, just feels HTML is a terrible wrong. after all, aren’t datastructure. we supposed to transmit just the model?
  • 18. Solution: Work the Server Client(JavaScript) Client Server(Ruby) Server A AJAX for D,C D HT B ML Td Data HTML Tc E L HTM C you either make 2 ajax requests OR you have a “wrapper” html template Still suboptimal because which repurposes html what if you need to use DRY, but inefficient as a data format for that data for something that has no template Even so, sending fully I.e. for a growl-like assembled views across notification. the wire, just feels HTML is a terrible wrong. after all, aren’t datastructure. we supposed to transmit just the model?
  • 19. Solution: Bring the Templates With You Client(JavaScript) Client Server(Ruby) Server A AJAX for D,C D B E C Ta Ta Tb Tc Td Tb Tc Td Te Te
  • 20. Solution: Bring the Templates With You Client(JavaScript) Client Server(Ruby) Server A AJAX for D,C D HTM L B Td Data Tc L E HTM C Ta Ta Tb Tc Td Tb Tc Td Te Te
  • 21. What this looks like in code.
  • 22. What this looks like in code.
  • 23. What this looks like in code.
  • 24. Advantages • Efficient, DRY • Data is data. Display is display. • Render without server when possible.
  • 25. Advantages • Efficient, DRY • Data is data. Display is display. • Render without server when possible. • Share implementations, not abstractions
  • 26. 4: Shared DSL • Implement a DSL in Javascript • Use the same script on client and server
  • 27. A JavaScript Customization Language Talk about requirement to edit in real time
  • 28. A JavaScript Customization Language Talk about requirement to edit in real time
  • 29. A JavaScript Customization Language Talk about requirement to edit in real time
  • 30. A JavaScript Customization Language Talk about requirement to edit in real time
  • 31. A JavaScript Customization Language The client uses it to: • render the property browser and editors • edit and update values in real-time The server uses it to: • lookup property names • set initial values
  • 32. Delve a bit into the history of javascript Server Extension
  • 33. What makes JavaScript Awesome? • Download completely and totally untrusted code from anywhere on the internet • Execute it in your browser knowing that your OS, Data and CPU are (relatively) safe from attack. • This has allowed for applications never thought possible.
  • 34. Code from Anywhere And here is Brendan Eich’s great innovation Server rendered here before your very eyes Client Server Awesome! Server
  • 35. Code from Anywhere And here is Brendan Eich’s great innovation rendered here before Client your very eyes Server Client Awesome! Client
  • 36. rb eval() = danger! Explain why this is safe Explain why rb.eval() is dangerous Because it only has access to what you tell it.
  • 37. rb eval() = danger! js eval() = safe! Explain why this is safe Explain why rb.eval() is dangerous Because it only has access to what you tell it.
  • 38. rb eval() = danger! js eval() = safe! Explain why this is safe Explain why rb.eval() is dangerous Because it only has access to what you tell it.
  • 39. rb eval() = danger! js eval() = safe! Explain why this is safe Explain why rb.eval() is dangerous Because it only has access to what you tell it.
  • 40. rb eval() = danger! js eval() = safe! Explain why this is safe Explain why rb.eval() is dangerous Because it only has access to what you tell it.
  • 41. 5. Remote Control • Run an agent written in Ruby • Expose specific actions to clients
  • 42. Process Control point out data format is whatever we want it to be, and can be extended to whatever we want.
  • 43. Process Control point out data format is whatever we want it to be, and can be extended to whatever we want.
  • 44. Process Control point out data format is whatever we want it to be, and can be extended to whatever we want.
  • 45. Process Control point out data format is whatever we want it to be, and can be extended to whatever we want.
  • 46. 6: Canvatar Script Store javascript Image Store image image++ Client • Extend an image server at run time • Use JavaScript to expose functionality implemented with RMagick or equivalent
  • 48. Pimp My Avatar 1) fetch the image
  • 49. Pimp My Avatar 1) fetch the image + 2) apply transform
  • 50. Pimp My Avatar 1) fetch the image + = 2) apply transform
  • 51. Ruby + JavaScript • Ruby as browser implementation • Ruby speaks JavaScript • Ruby wrapped in JavaScript armor • Let your imagination run wild Use ruby as a the implementation language of the browser Make ruby smarter by making it speak the browser’s language natively Use JavaScripts
  • 52.
  • 53. Thank You. • cowboyd@thefrontside.net • @cowboyd • http://github.com/cowboyd/therubyracer • http://github.com/cowboyd/therubyrhino • http://drunkandretired.com/ThePodcast

Notes de l'éditeur

  1. we build for all kinds of platforms. mostly the web, but even on your iphone, android, desktop, chances are you’ll still use javascript.
  2. The key point I want to make with this talk is just how many possibilities there are, and how many positive outcomes you can have when these guys join forces.