SlideShare a Scribd company logo
1 of 10
Download to read offline
Metaprogramming in Ruby


Creating languages in just a sec!




                               
                                    http://jon.is.emotionull.com
Creating a language

       Parsers from scratch
       Bison/yacc/lex 
       Metaprogramming FTW!




                                
Hacko!

       Example

         // this is a test (example.hacko)
         include ”stdio”
         main {
             printf ”Hello Mr. %s !”, ”Jon”
         }     



                                    
Bow to the masters

       Lisp
       Scheme
       Forth
       Smalltalk 




                      
Thinking again the problem

       Code as data
       Self modifying code
       Dynamic adding/removing classes/functions
       Describe the problem, don't solve it!




                                
Metaprogramming in the wild

       Web frameworks (Ruby On Rails)
       A.I
       DSL
       Configuration files
       ...




                               
But, hooooow???

       Function pointers (C,C++)
       Open classes (Ruby)
       Metaclasses (Python)
       Lists (Lisp/Scheme/Clojure)




                                
Speed penalty – Not always

       Premature optimization
       Fast and smart VM (JVM)
       Bottleneck is somewhere else
       You are not smart enough. Deal with it!




                               
Hacko!

       Implemented in ~ 10 minutes
       Looks like C
       Feels like C
       FULLY extensible
       Trivial to add new libraries
       You can use available Ruby libs
       VM ~ 25 lines!
                                 
 




    Thank for watching! Questions?




        http://jon.is.emotionull.com
           jon@emotionull.com
                     

More Related Content

What's hot

Rebol brainwasher
Rebol brainwasherRebol brainwasher
Rebol brainwasher
crazyaxe
 
PHP to Python with No Regrets
PHP to Python with No RegretsPHP to Python with No Regrets
PHP to Python with No Regrets
Alex Ezell
 
Coldfusion
ColdfusionColdfusion
Coldfusion
Ram
 

What's hot (13)

Consider the following BNF grammar: implement a recursive descent parser tha...
Consider the following BNF grammar:  implement a recursive descent parser tha...Consider the following BNF grammar:  implement a recursive descent parser tha...
Consider the following BNF grammar: implement a recursive descent parser tha...
 
Code rippa
Code rippaCode rippa
Code rippa
 
Rebol brainwasher
Rebol brainwasherRebol brainwasher
Rebol brainwasher
 
PHP to Python with No Regrets
PHP to Python with No RegretsPHP to Python with No Regrets
PHP to Python with No Regrets
 
Rebol
RebolRebol
Rebol
 
I35s
I35sI35s
I35s
 
Sistemas
Sistemas Sistemas
Sistemas
 
AddisDev Meetup ii: Golang and Flow-based Programming
AddisDev Meetup ii: Golang and Flow-based ProgrammingAddisDev Meetup ii: Golang and Flow-based Programming
AddisDev Meetup ii: Golang and Flow-based Programming
 
C c#
C c#C c#
C c#
 
Gdg dev fest 2107 to kotlin, with love
Gdg dev fest 2107   to kotlin, with loveGdg dev fest 2107   to kotlin, with love
Gdg dev fest 2107 to kotlin, with love
 
Coldfusion
ColdfusionColdfusion
Coldfusion
 
How to join open source development
How to join open source developmentHow to join open source development
How to join open source development
 
An Introduction to PyPy
An Introduction to PyPyAn Introduction to PyPy
An Introduction to PyPy
 

Viewers also liked

Viewers also liked (12)

Pyramids builders
Pyramids buildersPyramids builders
Pyramids builders
 
Tomame O DéJame
Tomame O DéJameTomame O DéJame
Tomame O DéJame
 
Modul p.point 2007
Modul p.point 2007Modul p.point 2007
Modul p.point 2007
 
Case Study - uvedení nového projektu - Galerie panenek DollsLand
Case Study - uvedení nového projektu - Galerie panenek DollsLandCase Study - uvedení nového projektu - Galerie panenek DollsLand
Case Study - uvedení nového projektu - Galerie panenek DollsLand
 
2
22
2
 
Topological Inference via Meshing
Topological Inference via MeshingTopological Inference via Meshing
Topological Inference via Meshing
 
Approximate Centerpoints with Proofs
Approximate Centerpoints with ProofsApproximate Centerpoints with Proofs
Approximate Centerpoints with Proofs
 
Internet, sociální sítě a nová media v marketingové komunikaci
Internet, sociální sítě a nová media v marketingové komunikaciInternet, sociální sítě a nová media v marketingové komunikaci
Internet, sociální sítě a nová media v marketingové komunikaci
 
Rails vs Web2py
Rails vs Web2pyRails vs Web2py
Rails vs Web2py
 
Internet & sociální sítě v marketingové komunikaci - přednáška VŠE 12/2012
Internet & sociální sítě v marketingové komunikaci - přednáška VŠE 12/2012Internet & sociální sítě v marketingové komunikaci - přednáška VŠE 12/2012
Internet & sociální sítě v marketingové komunikaci - přednáška VŠE 12/2012
 
Presentación2
Presentación2Presentación2
Presentación2
 
Online marketing & new media | BenedaGroup.com
Online marketing & new media | BenedaGroup.comOnline marketing & new media | BenedaGroup.com
Online marketing & new media | BenedaGroup.com
 

Similar to Metaprogramming in Ruby

蔡学镛 Rebol漫谈
蔡学镛   Rebol漫谈蔡学镛   Rebol漫谈
蔡学镛 Rebol漫谈
d0nn9n
 
Os Worthington
Os WorthingtonOs Worthington
Os Worthington
oscon2007
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
knoppix
 

Similar to Metaprogramming in Ruby (20)

Metaprogramming in Ruby
Metaprogramming in RubyMetaprogramming in Ruby
Metaprogramming in Ruby
 
IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the Rubyist
 
蔡学镛 Rebol漫谈
蔡学镛   Rebol漫谈蔡学镛   Rebol漫谈
蔡学镛 Rebol漫谈
 
Bridging Ousterhout's Dichotomy
Bridging Ousterhout's DichotomyBridging Ousterhout's Dichotomy
Bridging Ousterhout's Dichotomy
 
Ruby
RubyRuby
Ruby
 
Re-imaginging CakePHP
Re-imaginging CakePHPRe-imaginging CakePHP
Re-imaginging CakePHP
 
MacRuby For Ruby Developers
MacRuby For Ruby DevelopersMacRuby For Ruby Developers
MacRuby For Ruby Developers
 
Language Barriers
Language BarriersLanguage Barriers
Language Barriers
 
Os Worthington
Os WorthingtonOs Worthington
Os Worthington
 
2009 Eclipse Con
2009 Eclipse Con2009 Eclipse Con
2009 Eclipse Con
 
Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_future
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
 
Message Queues & Offline Processing with PHP
Message Queues & Offline Processing with PHPMessage Queues & Offline Processing with PHP
Message Queues & Offline Processing with PHP
 
Web Development with Smalltalk
Web Development with SmalltalkWeb Development with Smalltalk
Web Development with Smalltalk
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRuby
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
Ruby for devops
Ruby for devopsRuby for devops
Ruby for devops
 
10 Years of JavaScript
10 Years of JavaScript10 Years of JavaScript
10 Years of JavaScript
 
DSLs in JavaScript
DSLs in JavaScriptDSLs in JavaScript
DSLs in JavaScript
 

Recently uploaded

Recently uploaded (20)

Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Buy Epson EcoTank L3210 Colour Printer Online.pdf
Buy Epson EcoTank L3210 Colour Printer Online.pdfBuy Epson EcoTank L3210 Colour Printer Online.pdf
Buy Epson EcoTank L3210 Colour Printer Online.pdf
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 

Metaprogramming in Ruby

  • 2. Creating a language  Parsers from scratch  Bison/yacc/lex   Metaprogramming FTW!    
  • 3. Hacko!  Example // this is a test (example.hacko) include ”stdio” main {     printf ”Hello Mr. %s !”, ”Jon” }         
  • 4. Bow to the masters  Lisp  Scheme  Forth  Smalltalk     
  • 5. Thinking again the problem  Code as data  Self modifying code  Dynamic adding/removing classes/functions  Describe the problem, don't solve it!    
  • 6. Metaprogramming in the wild  Web frameworks (Ruby On Rails)  A.I  DSL  Configuration files  ...    
  • 7. But, hooooow???  Function pointers (C,C++)  Open classes (Ruby)  Metaclasses (Python)  Lists (Lisp/Scheme/Clojure)    
  • 8. Speed penalty – Not always  Premature optimization  Fast and smart VM (JVM)  Bottleneck is somewhere else  You are not smart enough. Deal with it!    
  • 9. Hacko!  Implemented in ~ 10 minutes  Looks like C  Feels like C  FULLY extensible  Trivial to add new libraries  You can use available Ruby libs  VM ~ 25 lines!    
  • 10.   Thank for watching! Questions? http://jon.is.emotionull.com jon@emotionull.com