[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
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)Imagine There’s No Source Code: Replay Diagnostic Location Information in Dynamic EDSL Meta-programmingProceedings of the 21st ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes10.1145/3679007.3685061(48-54)Online publication date: 13-Sep-2024
  • (2024)Effectful Software ContractsProceedings of the ACM on Programming Languages10.1145/36329308:POPL(2639-2666)Online publication date: 5-Jan-2024
  • (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
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

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
  • 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
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: 04 June 2011
Published in SIGPLAN Volume 46, Issue 6

Check for updates

Author Tags

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

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)53
  • Downloads (Last 6 weeks)3
Reflects downloads up to 01 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2024)Imagine There’s No Source Code: Replay Diagnostic Location Information in Dynamic EDSL Meta-programmingProceedings of the 21st ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes10.1145/3679007.3685061(48-54)Online publication date: 13-Sep-2024
  • (2024)Effectful Software ContractsProceedings of the ACM on Programming Languages10.1145/36329308:POPL(2639-2666)Online publication date: 5-Jan-2024
  • (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
  • (2021)Multi-stage programming with generative and analytical macrosProceedings of the 20th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences10.1145/3486609.3487203(110-122)Online publication date: 17-Oct-2021
  • (2021)LLJava live at the loop: a case for heteroiconic staged meta-programmingProceedings of the 18th ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes10.1145/3475738.3480942(113-126)Online publication date: 29-Sep-2021
  • (2019)Compiler generation for performance-oriented embedded DSLs (short paper)Proceedings of the 18th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences10.1145/3357765.3359520(94-101)Online publication date: 21-Oct-2019
  • (2018)Storm: a language platform for interacting and extensible languages (tool demo)Proceedings of the 11th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3276604.3276982(60-64)Online publication date: 24-Oct-2018
  • (2018)Deriving fluent internal domain-specific languages from grammarsProceedings of the 11th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3276604.3276621(187-199)Online publication date: 24-Oct-2018
  • (2018)Drop-In Help CentresProceedings of the 23rd Western Canadian Conference on Computing Education10.1145/3209635.3209642(1-6)Online publication date: 4-May-2018
  • (2017)SPLACM Transactions on Programming Languages and Systems10.1145/303920739:1(1-39)Online publication date: 6-Mar-2017
  • 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

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media