Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/2493288.2493289acmconferencesArticle/Chapter ViewAbstractPublication PagesplopConference Proceedingsconference-collections
research-article

Metaprogramming in Ruby: a pattern catalog

Published: 16 October 2010 Publication History
  • Get Citation Alerts
  • Abstract

    Modern programming languages provide extensive metaprogramming facilities. We understand metaprogramming as the utilization and modification of available language constructs and abstractions while staying inside the language. Metaprogramming requires a rich semantic model of the program that is represented as language constructs. The careful utilization of the constructs allows changing programs and sometimes even the semantics of other language constructs.
    There are several use-cases for these kinds of extensions: Runtime adaption, program generation, language customization or the design of Domain-Specific Languages (DSL). However, for using metaprogramming effectively, developers need to understand the mechanisms of metaprogramming and need a language that addresses these mechanisms. These are the prerequisites to communicate about metaprogramming and to actively use it in development.
    This paper's goal is to explore and highlight the metaprogramming facilities of the Ruby programming language. Ruby is an interpreted and fully object-oriented language. Any class and method -- even those of the built-in entities -- can be modified at runtime. We explain the mechanisms in the form of a pattern catalog that is structured along the object's initialization, declaration, composition, and modification. The core contribution is the sensitive grouping of related patterns that exist in literature and to reduce them to the dominant techniques they use. The pattern catalog can be used to communicate about Ruby's metaprogramming capabilities effectively. We explain the patterns with their context, problem, goals, consequences, known uses, and illustrate them in the context of an example application.

    References

    [1]
    Bachmann, P. 2006. Static and Metaprogramming Patterns and Static Frameworks. In Proceedings of the the 13th Conference on Pattern Languages of Programs (PLOP). ACM.
    [2]
    Correia, F. F., Ferreira, H. S., Flores, N., and Aguiar, A. Patterns for Consistent Software Documentation. In Proceedings of the 16th Conference for Pattern Langauges of Programs (PloP).
    [3]
    Czarnecki, K. and Eisenecker, U. W. 2000. Generative Programming: Methods, Tools, and Applications. Addison-Wesley, Boston, San Franciso et al.
    [4]
    Flanagan, D. and Matsumoto, Y. 2008. The Ruby Programming Language. O-Reilly Media, Sebastopol, USA.
    [5]
    Gamma, E., Helm, R., Johnson, R., and Vlissides, J. 1997. Design Patterns - Elements of Reusable Object-Oriented Software 10th Ed. Addison-Wesley, Reading, Harlow et al.
    [6]
    Guerra, E., Souza, J., and Fernandes, C. 2009. A Pattern Language for Metadata-based Frameworks. In Proceedings of the 16th COnference on Pattern Languages of Programs (PLOP). ACM.
    [7]
    Günther, S. and Sunkle, S. 2009a. Enabling Feature-Oriented Programming in Ruby. Technical report (Internet) FIN-016-2009, Otto-von-Guericke-Universität Magdeburg, Germany.
    [8]
    Günther, S. and Sunkle, S. 2009b. Feature-Oriented Programming with Ruby. In Proceedings of the First International Workshop on Feature-Oriented Software Development (FOSD). ACM, New York, 11--18.
    [9]
    Kiczales, G., Rivières, J. d., and Bobrow, D. G. 1995. The Art of the Metaobject Protocol 4th Ed. The MIT Press, Cambridge, London.
    [10]
    Olsen, R. 2007. Design Patterns in Ruby. Addison-Wesley, Upper Saddle River, Boston et al.
    [11]
    Perrotta, P. 2010. Metaprogramming Ruby. The Pragmatic Bookshelf, Raleigh.
    [12]
    Reenskaug, T. 1979. THING-MODEL-VIEW-EDITOR: An Example from a Planningsystem. Xerox PARC technical note. Available online http://heim.ifi.uio.no/trygver/1979/mvc-1/1979-05-MVC.pdf.
    [13]
    Thomas, D., Fowler, C., and Hunt, A. 2009. Programming Ruby 1.9 - The Pragmatic Programmers' Guide. The Pragmatic Bookshelf, Raleigh, USA.
    [14]
    Vandevoorde, D. and Josuttis, N. M. 2003. C++ Templates: The Complete Guide. Pearson Education, Boston.
    [15]
    von Dincklage, D. 2003. Making Patterns Explicit with Metaprogramming. In Proceedings of the 2nd international conference on Generative Programming and Component Engineering (GPCE). Springer-Verlag, New York, 287--306.

    Cited By

    View all
    • (2017)A Layer-based Approach to Hierarchical Dynamically-scoped Open ClassesJournal of Information Processing10.2197/ipsjjip.25.29625(296-307)Online publication date: 2017
    • (2017)A chrestomathy of DSL implementationsProceedings of the 10th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3136014.3136038(103-114)Online publication date: 23-Oct-2017

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    PLOP '10: Proceedings of the 17th Conference on Pattern Languages of Programs
    October 2010
    388 pages
    ISBN:9781450301077
    DOI:10.1145/2493288
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 16 October 2010

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Ruby
    2. dynamic programming languages
    3. metaprogramming

    Qualifiers

    • Research-article

    Funding Sources

    Conference

    PLoP '10
    Sponsor:

    Acceptance Rates

    PLOP '10 Paper Acceptance Rate 28 of 36 submissions, 78%;
    Overall Acceptance Rate 28 of 36 submissions, 78%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)13
    • Downloads (Last 6 weeks)1
    Reflects downloads up to 12 Aug 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2017)A Layer-based Approach to Hierarchical Dynamically-scoped Open ClassesJournal of Information Processing10.2197/ipsjjip.25.29625(296-307)Online publication date: 2017
    • (2017)A chrestomathy of DSL implementationsProceedings of the 10th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3136014.3136038(103-114)Online publication date: 23-Oct-2017

    View Options

    Get Access

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media