SlideShare uma empresa Scribd logo
1 de 10
Baixar para ler 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
                     

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Destaque

Destaque (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
 

Semelhante a Metaprogramming in Ruby

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

Semelhante a 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
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

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