ABSTRACT
Language-integrated meta-programming and extensible compilation have been recurring themes of programming languages since the invention of LISP. A recent real-world application of these techniques is the use of small meta-programs to specify database queries, as used in the Microsoft LINQ extensions for .NET. It is important that .NET languages such as F# are able to leverage the functionality provided by LINQ and related components for heterogeneous execution, both for pragmatic reasons and as a first step toward applying more disciplined, formal approaches to these problems. This paper explores the use of a modest meta-programming extension to F# to access and leverage the functionality of LINQ and other components. We do this by demonstrating an implementation of language integrated SQL queries using the LINQ/SQLMetal libraries. We also sketch two other applications: the execution of data-parallel quoted F# programs on a GPU via the Accelerator libraries, and dynamic native-code compilation via LINQ.
- B. Beckman, G. Bierman, and E. Meijer. LINQ: Reconciling Objects, Relations, and XML In the .NET Framework. In Accepted to appear in SIGMOD, 2006. Google ScholarDigital Library
- N. Benton, A. Kennedy, and C. V. Russo. Adventures in interoperability: the SML.NET experience. In PPDP '04: Proceedings of the 6th ACM SIGPLAN International conference on Principles and Practice of Declarative Programming, pages 215--226, New York, NY, USA, 2004. ACM Press. Google ScholarDigital Library
- P. N. Benton, A. J. Kennedy, and G. Russell. Compiling Standard ML to Java bytecodes. In 3rd ACM SIGPLAN International Conference on Functional Programming, September 1998. Google ScholarDigital Library
- K. Bhargavan, C. Fournet, A. Gordon, and S. Tse. Verified interoperable implementations of security protocols. In Computer Security Foundations Workshop (CSFW), 2006. Google ScholarDigital Library
- G. Bierman, E. Meijer, and W. Schulte. The essence of data access in Cω. In Proceedings on the 19th European Conference on Object Oriented Programming, pages 287--311, July 2005. Google ScholarDigital Library
- P. Buneman, L. Libkin, D. Suciu, V. Tannen, and L. Wong. Comprehension syntax. SIGMOD Rec., 23(1):87--96, 1994. Google ScholarDigital Library
- K. Czarnecki, J. O'Donnell, J. Striegnitz, and W. Taha. Dsl implementation in metaocaml, template haskell, and c++.Google Scholar
- J. Eckhardt, R. Kaiabachev, E. Pasalic, K. Swadi, and W. Taha. Implicitly Heterogeneous Multi-stage Programming. In Proceedings of GPCE '05, 2005. Google ScholarDigital Library
- ECMA International. ECMA Standard 334: C# language specification. See http://www.ecma-international.org.Google Scholar
- ECMA International. ECMA Standard 335: Common Language Infrastructure. See http://www.ecma-international.org.Google Scholar
- G. Ferrari, E. Moggi, and R. Pugliese. Metaklaim: a type safe multi-stage language for global computing. Mathematical. Structures in Comp. Sci., 14(3):367--395, 2004. Google ScholarDigital Library
- S. E. Ganz, A. Sabry, and W. Taha. Macros as multi-stage computations: type-safe, generative, binding macros in MacroML. In ICFP '01: Proceedings of the sixth ACM SIGPLAN International Conference on Functional Programming, pages 74--85. ACM Press, 2001. Google ScholarDigital Library
- M. Gordon, R. Milner, and C. Wadsworth. Edinburgh LCF: A mechanised logic of computation. In Lecture Notes in Computer Science, volume 78. Springer Verlag, 1979.Google Scholar
- J. Grundy, T. Melham, and J. O'Leary. A reflective functional language for hardware design and theorm proving. Technical Report PRG-RR-03-16, Oxford Univerity, Computing Laboratory, 2003.Google Scholar
- L. J. Guibas and D. K. Wyatt. Compilation and delayed evaluation in APL. In POPL '78: Proceedings of the 5th ACM SIGACT-SIGPLAN symposium on Principles of programming languages, pages 1--8, New York, NY, USA, 1978. ACM Press. Google ScholarDigital Library
- A. J. Kennedy and D. Syme. Design and implementation of Generics for the .NET Common Language Runtime. In Programming Language Design and Implementation. ACM, 2001. Google ScholarDigital Library
- B. A. LaMacchia, S. Lange, M. Lyons, R. Martin, and K. T. Price. .NET Framework Security. Pearson Education, 2002. Google ScholarDigital Library
- D. Leijen and E. Meijer. Domain specific embedded compilers. In 2nd USENIX Conference on Domain Specific Languages (DSL'99), pages 109--122, Austin, Texas, Oct. 1999. Also appeared in ACM SIGPLAN Notices 35, 1, (Jan. 2000), see also http://www.haskell.org/haskellDB/. Google ScholarDigital Library
- D. Luebke, M. Harris, J. Krüger, T. Purcell, N. Govindaraju, I. Buck, C. Woolley, and A. Lefohn. Gpgpu: general purpose computation on graphics hardware. In GRAPH '04: Proceedings of the conference on SIGGRAPH 2004 course notes, page 33, New York, NY, USA, 2004. ACM Press. Google ScholarDigital Library
- Microsoft Corporation. The LINQ May 2006 Preview, 2006. See http://msdn.microsoft.com/data/ref/linq/.Google Scholar
- M. Odersky, M. Sulzmann, and M. Wehr. Type Inference with Constrained Types. TAPOS, 5(1), 1999. Google ScholarDigital Library
- J. A. Orenstein and D. N. Kamber. Accessing a relational database through an object-oriented database interface. In VLDB '95: Proceedings of the 21th International Conference on Very Large Data Bases, pages 702--705, San Francisco, CA, USA, 1995. Morgan Kaufmann Publishers Inc. Google ScholarDigital Library
- J. Pobar and D. Russi. Late-bound invocation notes and Lightweight Code Gen, 2004. MSDN blog entry, See http://blogs.msdn.com/joelpob/archive/2004/04/01/105862.aspx.Google Scholar
- T. Sheard, Z. Benaissa, and E. Pasalic. DSL implementation using staging and monads. In Domain-Specific Languages, pages 81--94, 1999. Google ScholarDigital Library
- T. Sheard and S. P. Jones. Template Meta-programming for Haskell. In Haskell '02: Proceedings of the 2002 ACM SIGPLAN workshop on Haskell, pages 1--16, New York, NY, USA, 2002. ACM Press. Google ScholarDigital Library
- D. Syme. Declarative Theorem Proving for Operational Semantics. PhD thesis, University of Cambridge, 1998.Google Scholar
- D. Syme. ILX: Extending the .NET Common IL for Functional Language Interoperability. Electronic Notes in Theoretical Computer Science, 59(1), 2001.Google Scholar
- D. Syme and J. Margetson. The F# website, 2006. See http://research.microsoft.com/fsharp/.Google Scholar
- W. Taha and other contributors. MetaOCaml: a compiled, type-safe multi-stage programming language, 2006. See http://www.metaocaml.org/.Google Scholar
- W. Taha and T. Sheard. MetaML and multi-stage programming with explicit annotations. Theoretical Computer Science, 248(1--2):211--242, 2000. Google ScholarDigital Library
- D. Tarditi, S. Puri, and J. Oglesby. Accelerator: simplified programming of graphics processing units for general-purpose uses via data-parallelism. Technical Report MSR-TR-2005-184, Microsoft Research, December 2005.Google Scholar
- P. Wadler. Views: a way for pattern matching to cohabit with data abstraction. In POPL '87: Proceedings of the 14th ACM SIGACT-SIGPLAN symposium on Principles of programming languages, pages 307--313, New York, NY, USA, 1987. ACM Press. Google ScholarDigital Library
- M. Wand. The theory of fexprs is trivial. Lisp and Symbolic Computation, 10(3):189--199, 1998. Google ScholarDigital Library
- H. Xi, C. Chen, and G. Chen. Guarded recursive datatype constructors. In POPL '03: Proceedings of the 30th ACM SIGPLAN-SIGACT symposium on Principles of Programming Languages, pages 224--235, New York, NY, USA, 2003. ACM Press. Google ScholarDigital Library
Index Terms
- Leveraging .NET meta-programming components from F#: integrated queries and interoperable heterogeneous execution
Recommendations
Directly reflective meta-programming
Existing meta-programming languages operate on encodings of programs as data. This paper presents a new meta-programming language, based on an untyped lambda calculus, in which structurally reflective programming is supported directly, without any ...
Domain specific language implementation via compile-time meta-programming
Domain specific languages (DSLs) are mini-languages that are increasingly seen as being a valuable tool for software developers and non-developers alike. DSLs must currently be created in an ad-hoc fashion, often leading to high development costs and ...
Profile-guided meta-programming
PLDI '15: Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and ImplementationContemporary compiler systems such as GCC, .NET, and LLVM incorporate profile-guided optimizations (PGOs) on low-level intermediate code and basic blocks, with impressive results over purely static heuristics. Recent work shows that profile information ...
Comments