skip to main content
10.1145/2493288.2493291acmconferencesArticle/Chapter ViewAbstractPublication PagesplopConference Proceedingsconference-collections
research-article

Design principles for internal domain-specific languages: a pattern catalog illustrated by Ruby

Published:16 October 2010Publication History

ABSTRACT

Some programming languages, especially dynamic programming languages, offer suitable mechanisms for the construction of internal domain-specific languages (DSL). Internal DSLs inherit the facilities of their host language such as the availability of libraries, frameworks, tool support, and other DSLs. When developing an internal DSL, there are two challenges. First, to cope with the host language's syntactic and semantic restrictions. Careful and thoughtful extensions and modifications of the host language are crucial to overcome these restrictions without reverting to poor language design. Second, to support several design principles that are genuine for a DSL. Although there is an extensive body of knowledge about DSL design principles and desirable quality properties, it remains difficult to apply them, or to reason about whether a particular DSL exhibits specific desirable principles.

Our objective is to put the two perspectives together. We research the most important design principles of a DSL and show how different patterns can be used to support these principles. This allows us to produce an extensive pattern catalog which is the foundation of principled approach for designing internal DSLs. The patterns can be used to assess the design quality of a DSL and structure its implementation. In particular, we show a complex DSL example illustrating each principle and the corresponding patterns. While we stick to Ruby for the explanation and application of the patterns, we also name known uses in Python, Scala, and Smalltalk. Patterns are explained with their context, problem, forces, solution, and consequences. We also explain the patterns with the classical structure of intent, motivation, forces, implementation and their consequences. Finally we reflect upon the pattern utilization by discussing their strengths and weaknesses.

References

  1. Agosta, G. and Pelosi, G. 2007. A Domain Specific Language for Cryptography. In Proceedings of the Forum on specification and Design Languages (FDL). ECSI, 159--164.Google ScholarGoogle Scholar
  2. Arnold, B. R. T., Deursen, A. V., and Res, M. 1995. Algebraic Specification of a Language for describing Financial Products. In ICSE-17 Workshop on Formal Methods Application in Software Engineering. IEEE, 6--13.Google ScholarGoogle Scholar
  3. Batory, D., Sarvela, J. N., and Rauschmayer, A. 2003. Scaling Step-Wise Refinement. In Proceedings of the 25th International Conference on Software Engineering (ICSE). IEEE Computer Society, Washington, 187--197. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Bennett, M., Borgen, R., Havelund, K., Ingham, M., and Wagner, D. 2008. Development of a Prototype Domain-Specific Language for Monitor and Control Systems. In Aerospace Conference. IEEE Computer Society, 1--18.Google ScholarGoogle Scholar
  5. Bentley, J. 1986. Programming Pearls: Little Languages. Communications of the ACM 29, 8, 711--721. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Black, A. P., Ducasse, S., Nierstrasz, O., and Pollet, D. 2009a. Pharo by Example. Square Bracket Associates.Google ScholarGoogle Scholar
  7. Black, A. P., Ducasse, S., Nierstrasz, O., and Pollet, D. 2009b. Squeak by Example 1st revised Ed. Square Bracket Associates. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Booch, G. 1994. Object-Oriented Analysis and Design with Applications 2nd Ed. Addison Wesley Longman, Redwood City, CA, USA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Bruce, D. 1997. What makes a good Domain-Specific Language? APOSTLE, and its Approach to Parallel Discrete Event Simulation. In First ACM SIGPLAN Workshop on Domain-Specific Languages (DSL). University of Illinois Computer Science, Paris, France, 17--35.Google ScholarGoogle Scholar
  10. Cannon, B. and Wohlstadter, E. 2007. Controlling Access to Resources within the Python Interpreter. Proceedings of the Second EECE.Google ScholarGoogle Scholar
  11. Coplien, J. O. 1999. Multi-paradigm design for C++. Addison-Wesley, Boston, San Francisco, et al. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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). Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Costagliola, G., Delucia, A., Orefice, S., and Polese, G. 2002. A classification framework to support the design of visual languages. Journal of Visual Languages & Computing 13, 6, 573--600.Google ScholarGoogle ScholarCross RefCross Ref
  14. Cunningham, H. C. 2008. A Little Language for Surveys: Constructing an Internal DSL in Ruby. In Proceedings of the 46th Annual Southeast Regional Conference (ACM-SE). ACM, New York, 282--287. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Czarnecki, K. and Eisenecker, U. W. 2000. Generative Programming: Methods, Tools, and Applications. Addison-Wesley, Boston, San Franciso et al. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Dinkelaker, T. and Mezini, M. 2008. Dynamically Linked Domain-Specific Extensions for Advice Languages. In Proceedings of the 2008 AOSD Workshop on Domain-Specific Aspect Languages (DSAL). ACM, New York, 1--7. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Flanagan, D. and Matsumoto, Y. 2008. The Ruby Programming Language. O-Reilly Media, Sebastopol, USA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Foote B, J. Y. 1998. Metadata and Active Object Models. In Proceedings of the 5th Conference on Pattern Languages of Programs (PLOP). Washington University Department of Computer Science, Washington, USA.Google ScholarGoogle Scholar
  19. 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.Google ScholarGoogle Scholar
  20. Groote, J. F., Van Vlijmen, S. F. M., and Koorn, J. W. C. 1995. The Safety Guaranteeing System at Station Hoorn-Kersenboogerd. In Proceedings of the Tenth Annual Conference on Computer Assurance Systems Integrity, Software Safety and Process Security (COMPASS '95). IEEE, 57--68.Google ScholarGoogle Scholar
  21. 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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Günther, S. 2009. Engineering Domain-Specific Languages with Ruby. In 3. Workshop des Centers for Very Large Business Applications (CVLBA), H.-K. Arndt and H. Krcmar, Eds. Shaker, Aachen, 11--21.Google ScholarGoogle Scholar
  23. Haase, A. 2007. Patterns for the Definition of Programming Languages. In Proceedings of 12th European Conference on Pattern Languages of Programs (EuroPLoP).Google ScholarGoogle Scholar
  24. Høst, E. W. and Østvold, B. M. 2008. The java programmer's phrase book. In Software Language Engineering. First International Conference on Software Language Engineering (SLE), 5452, 322--341.Google ScholarGoogle Scholar
  25. Hudak, P. 1998. Modular Domain Specific Languages and Tools. In Proceedings of the Fifth International Conference on Software Reuse (ICSR), P. Davenbu and J. Poulin, Eds. IEEE, Washington, 134--142. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Kang, K., Cohen, S., Hess, J., Novak, W., and Peterson, A. 1990. Feature-Oriented Domain Analysis (FODA) Feasibility Study. Tech. Rep. CMU/SEI-90-TR-21, Software Engineering Institute, Carnegie Mellon University, USA.Google ScholarGoogle Scholar
  27. Ladd, D. A. and Ramming, J. C. 1994. Two Application Languages in Software Production. In Proceedings of the USENIX Very High Level Languages Symposium (VHLLS). USENIX Association, Berkeley, CA, USA, 10--18. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Landin, P. J. 1966. The Next 700 Programming Languages. Communications of the ACM 9, 3, 157--166. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Latry, F., Mercadal, J., and Consel, C. 2007. Staging Telephony Service Creation: A Language Approach. In Proceedings of the 1st international conference on Principles, systems and applications of IP telecommunications (IPTComm). ACM, New York, 99--110. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Lopez-Herrejon, R. E. and Batory, D. 2001. A Standard Problem for Evaluating Productline Methodologies. In Proceedings of the 3rd International Conference on Generative and Component-Based Software Engineering (GCSE), J. Bosch, Ed. Lecture Notes in Computer Science Series, vol. 2186. Springer-Verlag, London, 10--24. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Lutz, M. 2009. Learning Python 4th Ed. O'Reilly Media, Sebastopol. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. McKeeman, W. M. 1976. Programming language design. In Compiler Construction, An Advanced Course, 2nd ed. Springer-Verlag, London, UK, 514--524. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Mernik, M., Heering, J., and Sloane, A. M. 2005. When and How to Develop Domain-Specific Languages. ACM Computing Survey 37, 4, 316--344. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Moody, D. L. 2009. The "Physics" of Notations: Toward a Scientific Basis for Constructing Visual Notations in Software Engineering. IEEE Transactions on Software Engineering 35, 756--779. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Munnelly, J. and Clarke, S. 2008. A Domain-Specific Language for Ubiquitous Healthcare. In Proceedings of the 3rd International Conference on Pervasive Computing and Applications (ICSPA). IEEE, 757--762.Google ScholarGoogle Scholar
  36. Odersky, M., Spoon, L., and Venners, B. 2008. Programming in Scala. Artima Press, Mountain View, California, USA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Pane, J. F. 2004. Dissertation. Ph.D. thesis, Carnegie Mellon University, Computer Science Department.Google ScholarGoogle Scholar
  38. Perrotta, P. 2010. Metaprogramming Ruby. The Pragmatic Bookshelf, Raleigh. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Sebesta, R. W. 1999. Concepts of Programming Languages. Addison-Wesley, Reading, Harlow et al. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Sharp, A. 1997. Smalltalk by Example. McGraw-Hill Publishing Co.Google ScholarGoogle Scholar
  41. Spiewak, D. and Zhao, T. 2009. ScalaQL: Language-Integrated Database Queries for Scala. In Proceedings of the 2nd International Conference on Software Language Engineering (SLE), M. van den Brand, D. Gaševic, and J. Gray, Eds. Lecture Notes in Computer Science Series, vol. 5969. Springer-Verlag, Berlin, Heidelberg, 154--163. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Spinellis, D. 2001. Notable Design Patterns for Domain-Specific Languages. Journal of Systems and Software 56, 1, 91--99. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Summerfield, M. 2010. Programming in Python 3: A Complete Introduction to the Python Programming Language 2nd Ed. Addison-Wesley, Upper Saddle River, Boston et al. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Tanter, É. 2008. Contextual Values. In Proceedings of the 2008 Symposium on Dynamic Languages (DLS). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Thibault, S., Marlet, R., and Consel, C. 1997. A Domain-Specific Language for Video Device Drivers: from Design to Implementation. 11--26.Google ScholarGoogle Scholar
  46. Thomas, D., Fowler, C., and Hunt, A. 2009. Programming Ruby 1.9 - The Pragmatic Programmers' Guide. The Pragmatic Bookshelf, Raleigh, USA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. Van Deursen, A., Klint, P., and Visser, J. 2000. Domain-Specific Languages: An Annotated Bibliography. ACM SIGPLAN Notices 35, 6, pp. 26--36. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Wampler, D. and Payne, A. 2009. Programming Scala. O'Reilly Media, Sebastopol, USA.Google ScholarGoogle Scholar
  49. Weinberg, G. M. 1971. The Philosophy of Programming Languages. John Wiley & Sons, New York.Google ScholarGoogle Scholar
  50. Withey, J. 1996. Investment Analysis of Software Assets for Product Lines. Technical Report CMU/SEI96-TR-010, Software Engineering Institute, Carnegie Mellon University, USA.Google ScholarGoogle Scholar
  51. Zdun, U. and Strembeck, M. 2009. Reusable Architectural Decisions for DSL Design: Foundational Decisions in DSL Projects. In Proceedings of the 14th Annual European Conference on Pattern Languages of Programming (EuroPLoP), A. Kelly and M. Weiss, Eds. CEUR, RWTH Aachen, Aachen, Germany.Google ScholarGoogle Scholar

Index Terms

  1. Design principles for internal domain-specific languages: a pattern catalog illustrated by Ruby

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • 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

      Copyright © 2010 ACM

      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]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 16 October 2010

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      PLOP '10 Paper Acceptance Rate28of36submissions,78%Overall Acceptance Rate28of36submissions,78%

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader