SlideShare una empresa de Scribd logo
1 de 10
Descargar para leer sin conexión
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
                     

Más contenido relacionado

La actualidad más candente

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...hwbloom143
 
Rebol brainwasher
Rebol brainwasherRebol brainwasher
Rebol brainwashercrazyaxe
 
PHP to Python with No Regrets
PHP to Python with No RegretsPHP to Python with No Regrets
PHP to Python with No RegretsAlex Ezell
 
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 ProgrammingSamuel Lampa
 
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 loveAyman Mahfouz
 
Coldfusion
ColdfusionColdfusion
ColdfusionRam
 
How to join open source development
How to join open source developmentHow to join open source development
How to join open source developmentKan-Ru Chen
 

La actualidad más candente (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
 

Destacado

Tomame O DéJame
Tomame O DéJameTomame O DéJame
Tomame O DéJameborlcan
 
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 DollsLandBenedaGroup.com
 
Topological Inference via Meshing
Topological Inference via MeshingTopological Inference via Meshing
Topological Inference via MeshingDon Sheehy
 
Approximate Centerpoints with Proofs
Approximate Centerpoints with ProofsApproximate Centerpoints with Proofs
Approximate Centerpoints with ProofsDon Sheehy
 
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é komunikaciBenedaGroup.com
 
Rails vs Web2py
Rails vs Web2pyRails vs Web2py
Rails vs Web2pyjonromero
 
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/2012BenedaGroup.com
 
Presentación2
Presentación2Presentación2
Presentación2ferpal
 
Online marketing & new media | BenedaGroup.com
Online marketing & new media | BenedaGroup.comOnline marketing & new media | BenedaGroup.com
Online marketing & new media | BenedaGroup.comBenedaGroup.com
 

Destacado (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 a Metaprogramming in Ruby

IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the RubyistWill Green
 
蔡学镛 Rebol漫谈
蔡学镛   Rebol漫谈蔡学镛   Rebol漫谈
蔡学镛 Rebol漫谈d0nn9n
 
Bridging Ousterhout's Dichotomy
Bridging Ousterhout's DichotomyBridging Ousterhout's Dichotomy
Bridging Ousterhout's Dichotomyguest2838a0
 
Re-imaginging CakePHP
Re-imaginging CakePHPRe-imaginging CakePHP
Re-imaginging CakePHPGraham Weldon
 
MacRuby For Ruby Developers
MacRuby For Ruby DevelopersMacRuby For Ruby Developers
MacRuby For Ruby DevelopersRenzo Borgatti
 
Os Worthington
Os WorthingtonOs Worthington
Os Worthingtonoscon2007
 
2009 Eclipse Con
2009 Eclipse Con2009 Eclipse Con
2009 Eclipse Conguest29922
 
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_futureTakayuki Muranushi
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSkills Matter
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorialknoppix
 
Message Queues & Offline Processing with PHP
Message Queues & Offline Processing with PHPMessage Queues & Offline Processing with PHP
Message Queues & Offline Processing with PHPmarcelesser
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBrian Sam-Bodden
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Mark Menard
 
Ruby for devops
Ruby for devopsRuby for devops
Ruby for devopsAdam Klein
 
10 Years of JavaScript
10 Years of JavaScript10 Years of JavaScript
10 Years of JavaScriptMike de Boer
 

Similar 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

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
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 WorkerThousandEyes
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 

Último (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

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