skip to main content
10.1145/1993498.1993514acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
research-article

Languages as libraries

Published: 04 June 2011 Publication History

Abstract

Programming language design benefits from constructs for extending the syntax and semantics of a host language. While C's string-based macros empower programmers to introduce notational shorthands, the parser-level macros of Lisp encourage experimentation with domain-specific languages. The Scheme programming language improves on Lisp with macros that respect lexical scope.
The design of Racket---a descendant of Scheme---goes even further with the introduction of a full-fledged interface to the static semantics of the language. A Racket extension programmer can thus add constructs that are indistinguishable from "native" notation, large and complex embedded domain-specific languages, and even optimizing transformations for the compiler backend. This power to experiment with language design has been used to create a series of sub-languages for programming with first-class classes and modules, numerous languages for implementing the Racket system, and the creation of a complete and fully integrated typed sister language to Racket's untyped base language.
This paper explains Racket's language extension API via an implementation of a small typed sister language. The new language provides a rich type system that accommodates the idioms of untyped Racket. Furthermore, modules in this typed language can safely exchange values with untyped modules. Last but not least, the implementation includes a type-based optimizer that achieves promising speedups. Although these extensions are complex, their Racket implementation is just a library, like any other library, requiring no changes to the Racket implementation.

References

[1]
Jonathan Bachrach and Keith Playford. The Java syntactic extender. In Proc. Conf. Object-Oriented Programming Systems, Languages, and Applications, pp. 31--42, 2001.
[2]
Eli Barzilay and John Clements. Laziness Without All the Hard Work. In Proc. Works. Functional and Declarative Programming in Education, pp. 9--13, 2005.
[3]
Martin Bravenboer and Eelco Visser. Concrete syntax for objects: domainspecific language embedding and assimilation without restrictions. In Proc. Conf. Object-Oriented Programming Systems, Languages, and Applications, pp. 365--383, 2004.
[4]
John Clements, Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, and Shriram Krishnamurthi. Fostering Little Languages. Dr. Dobb's Journal, pp. 16--24, 2004.
[5]
William D. Clinger and Lars Thomas Hansen. Lambda, the ultimate label or a simple optimizing compiler for Scheme. In Proc. Conf. on LISP and functional programming, pp. 128--139, 1994.
[6]
Russ Cox, Tom Bergan, Austin T. Clements, Frans Kaashoek, and Eddie Kohler. Xoc, an extension-oriented compiler for systems programming. In Proc. Conf. Architectural Support for Programming Languages and Operating Systems, pp. 244--254, 2008.
[7]
Ryan Culpepper and Matthias Felleisen. Debugging hygienic macros. Science of Computer Programming 75(7), pp. 496--15, 2010.
[8]
Ryan Culpepper and Matthias Felleisen. Fortifying macros. In Proc. International Conf. on Functional Programming, pp. 235--246, 2010.
[9]
Ryan Culpepper, Scott Owens, and Matthew Flatt. Syntactic abstraction in component interfaces. In Proc. Conf. Generative Programming and Component Engineering, pp. 373--388, 2005.
[10]
Ryan Culpepper, Sam Tobin-Hochstadt, and Matthias Felleisen. Advanced Macrology and the Implementation of Typed Scheme. In Proc. Scheme and Functional Programming, 2007.
[11]
R. Kent Dybvig. Chez Scheme Version 8 User's Guide. Cadence Research Systems, 2009.
[12]
R. Kent Dybvig, Robert Hieb, and Carl Bruggeman. Syntactic abstraction in Scheme. Lisp and Symbolic Computation 5(4), pp. 295--326, 1992.
[13]
Marc Feeley and James S. Miller. A parallel virtual machine for efficient Scheme compilation. In Proc. Conf. on LISP and Functional Programming, pp. 119--130, 1990.
[14]
Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, and Shriram Krishnamurthi. Building Little Languages With Macros. Dr. Dobb's Journal, pp. 45--49, 2004.
[15]
David Fisher and Olin Shivers. Static semantics for syntax objects. In Proc. International Conf. on Functional Programming, pp. 111--121, 2006.
[16]
David Fisher and Olin Shivers. Building language towers with Ziggurat. J. of Functional Programming 18(5-6), pp. 707--780, 2008.
[17]
Matthew Flatt. Composable and compilable macros: you want it when? In Proc. International Conf. on Functional Programming, pp. 72--83, 2002.
[18]
Matthew Flatt, Eli Barzilay, and Robert Bruce Findler. Scribble: closing the book on ad-hoc documentation tools. In Proc. International Conf. on Functional Programming, pp. 109--120, 2009.
[19]
Matthew Flatt and Matthias Felleisen. Units: Cool modules for HOT languages. In Proc. Conf. on Programming Language Design and Implementation, pp. 236--248, 1998.
[20]
Matthew Flatt, Robert Bruce Findler, and Matthias Felleisen. Scheme with classes, mixins, and traits. In Proc. Asian Symp. on Programming Languages and Systems, pp. 270--289, 2006.
[21]
Matthew Flatt and PLT. Reference: Racket. PLT Inc., PLT-TR-2010-1, 2010. http://racket-lang.org/tr1/.
[22]
Richard P. Gabriel. Performance and Evaluation of LISP Systems. MIT Press, 1985.
[23]
Anwar Ghuloum, Amanda Sharp, Noah Clemons, Stefanus Du Toit, Rama Malladi, Mukesh Gangadhar, Michael McCool, and Hans Pabst. Array Building Blocks: A Flexible Parallel Programming Model for Multicore and Many-Core Architectures. Dr. Dobb's Journal, 2010.
[24]
Pieter H. Hartel, Marc Feeley, Martin Alt, Lennart Augustsson, Peter Baumann, Marcel Beemster, Emmanuel Chailloux, Christine H. Flood, Wolfgang Grieskamp, John H. G. van Groningen, Kevin Hammond, BogumiB Hausman, Melody Y. Ivory, Richard E. Jones, Jasper Kamperman, Peter Lee, Xavier Leroy, Rafael D. Lins, Sandra Loosemore, Niklas Röjemo, Manuel Serrano, Jean-Pierre Talpin, Jon Thackray, Stephen Thomas, Pum Walters, Pierre Weis, and E.P. Wentworth. Benchmarking implementations of functional languages with 'pseudoknot' a float-intensive benchmark. J. of Functional Programming 6(4), pp. 621--655, 1996.
[25]
Manuel V. Hermenegildo, Francisco Bueno, Manuel Carro, Pedro Lopez, José F. Morales, and German Puebla. An overview of the Ciao multiparadigm language and program development environment and its design philosophy. In Concurrency, Graphs and Models. Springer-Verlag, pp. 209--237, 2008.
[26]
Richard Andrew Kelsey. Compilation by Program Transformation. PhD dissertation, Yale University, 1989.
[27]
Shriram Krishnamurthi. Linguistic Reuse. PhD dissertation, Rice University, 2001.
[28]
Shriram Krishnamurthi, Peter Walton Hopkins, Jay McCarthy, Paul T. Graunke, Greg Pettyjohn, and Matthias Felleisen. Implementation and use of the PLT Scheme web server. Higher-Order and Symbolic Computing 20(4), pp. 431--460, 2007.
[29]
Simon Marlow. Haskell 2010 Language Report. 2010.
[30]
Robin Milner, Mads Tofte, Robert Harper, and David MacQueen. The Definition of Standard ML, Revised Edition. MIT Press, 1997.
[31]
Nathaniel Nystrom, Michael Clarkson, and Andrew Myers. Polyglot: an extensible compiler framework for Java. In Proc. International Conf. on Compiler Construction, pp. 138--152, 2003.
[32]
Simon L Peyton Jones. Compiling Haskell by program transformation a report from the trenches. In Proc. European Symp. on Programming, pp. 18--44, 1996.
[33]
Hari Prashanth K R and Sam Tobin-Hochstadt. Functional data structures for Typed Racket. In Proc. Works. Scheme and Functional Programming, pp. 1--7, 2010.
[34]
Manuel Serrano and Pierre Weis. Bigloo: a portable and optimizing compiler for strict functional languages. In Proc. Static Analysis Symp., pp. 366--381, 1995.
[35]
Michael Sperber, Matthew Flatt, Anton Van Straaten, R. Kent Dybvig, Robert Bruce Findler, and Jacob Matthews. Revised6 report on the algorithmic language Scheme. J. of Functional Programming 19(S1), pp. 1--301, 2009.
[36]
Guy L. Steele Jr. Common Lisp: The Language. Second edition. Digital Press, 1994.
[37]
Guy L. Steele Jr. Growing a language, Keynote at OOPSLA 1998. Higher-Order and Symbolic Computation 12(3), pp. 221--236, 1999.
[38]
Guy L. Steele Jr. and Richard P. Gabriel. The evolution of Lisp. In Proc. Conf. on History of Programming Languages, pp. 231--270, 1993.
[39]
T. Stephen Strickland, Sam Tobin-Hochstadt, and Matthias Felleisen. Practical Variable-Arity Polymorphism. In Proc. European Symp. on Programming, 2009.
[40]
Sam Tobin-Hochstadt and Matthias Felleisen. Interlanguage refactoring: from scripts to programs. In Proc. Dynamic Languages Symp., pp. 964--974, 2006.
[41]
Sam Tobin-Hochstadt and Matthias Felleisen. The design and implementation of Typed Scheme. In Proc. Symp. on Principles of Programming Languages, pp. 395--406, 2008.
[42]
Sam Tobin-Hochstadt and Matthias Felleisen. Logical types for untyped languages. In Proc. International Conf. on Functional Programming, pp. 117--128, 2010.
[43]
Eugene Kohlbecker. Syntactic Extensions in the Programming Language Lisp. PhD dissertation, Indiana University, 1986.

Cited By

View all
  • (2024)Programming Languages for the Future of Design ComputationProceedings of the 2024 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software10.1145/3689492.3689812(241-265)Online publication date: 17-Oct-2024
  • (2024)DSLs in Racket: You Want It How, Now?Proceedings of the 17th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3687997.3695645(84-103)Online publication date: 17-Oct-2024
  • (2024)Effectful Software ContractsProceedings of the ACM on Programming Languages10.1145/36329308:POPL(2639-2666)Online publication date: 5-Jan-2024
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
PLDI '11: Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation
June 2011
668 pages
ISBN:9781450306638
DOI:10.1145/1993498
  • General Chair:
  • Mary Hall,
  • Program Chair:
  • David Padua
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 46, Issue 6
    PLDI '11
    June 2011
    652 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/1993316
    Issue’s Table of Contents
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: 04 June 2011

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. extensible languages
  2. macros
  3. modules
  4. typed racket

Qualifiers

  • Research-article

Conference

PLDI '11
Sponsor:

Acceptance Rates

Overall Acceptance Rate 406 of 2,067 submissions, 20%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)48
  • Downloads (Last 6 weeks)0
Reflects downloads up to 14 Feb 2025

Other Metrics

Citations

Cited By

View all
  • (2024)Programming Languages for the Future of Design ComputationProceedings of the 2024 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software10.1145/3689492.3689812(241-265)Online publication date: 17-Oct-2024
  • (2024)DSLs in Racket: You Want It How, Now?Proceedings of the 17th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3687997.3695645(84-103)Online publication date: 17-Oct-2024
  • (2024)Effectful Software ContractsProceedings of the ACM on Programming Languages10.1145/36329308:POPL(2639-2666)Online publication date: 5-Jan-2024
  • (2024) i C o L a +Journal of Systems and Software10.1016/j.jss.2024.111979211:COnline publication date: 2-Jul-2024
  • (2023)A Haskell Library for Adaptable Parsing Expression GrammarsProceedings of the XXVII Brazilian Symposium on Programming Languages10.1145/3624309.3624313(73-81)Online publication date: 25-Sep-2023
  • (2023)Rhombus: A New Spin on Macros without All the ParenthesesProceedings of the ACM on Programming Languages10.1145/36228187:OOPSLA2(574-603)Online publication date: 16-Oct-2023
  • (2023)Collaborative Data Science using Scalable HomoiconicityACM SIGMOD Record10.1145/3582302.358231651:4(54-55)Online publication date: 25-Jan-2023
  • (2022)iCoLa: A Compositional Meta-language with Support for Incremental Language DevelopmentProceedings of the 15th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3567512.3567529(202-215)Online publication date: 29-Nov-2022
  • (2022)Relational compilation for performance-critical applications: extensible proof-producing translation of functional models into low-level codeProceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation10.1145/3519939.3523706(918-933)Online publication date: 9-Jun-2022
  • (2022)IRDL: an IR definition language for SSA compilersProceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation10.1145/3519939.3523700(199-212)Online publication date: 9-Jun-2022
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media