skip to main content
10.1145/1159876.1159884acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
Article

Leveraging .NET meta-programming components from F#: integrated queries and interoperable heterogeneous execution

Published:16 September 2006Publication History

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.

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. K. Bhargavan, C. Fournet, A. Gordon, and S. Tse. Verified interoperable implementations of security protocols. In Computer Security Foundations Workshop (CSFW), 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. P. Buneman, L. Libkin, D. Suciu, V. Tannen, and L. Wong. Comprehension syntax. SIGMOD Rec., 23(1):87--96, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. K. Czarnecki, J. O'Donnell, J. Striegnitz, and W. Taha. Dsl implementation in metaocaml, template haskell, and c++.Google ScholarGoogle Scholar
  8. J. Eckhardt, R. Kaiabachev, E. Pasalic, K. Swadi, and W. Taha. Implicitly Heterogeneous Multi-stage Programming. In Proceedings of GPCE '05, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. ECMA International. ECMA Standard 334: C# language specification. See http://www.ecma-international.org.Google ScholarGoogle Scholar
  10. ECMA International. ECMA Standard 335: Common Language Infrastructure. See http://www.ecma-international.org.Google ScholarGoogle Scholar
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle Scholar
  14. 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 ScholarGoogle Scholar
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. B. A. LaMacchia, S. Lange, M. Lyons, R. Martin, and K. T. Price. .NET Framework Security. Pearson Education, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. Microsoft Corporation. The LINQ May 2006 Preview, 2006. See http://msdn.microsoft.com/data/ref/linq/.Google ScholarGoogle Scholar
  21. M. Odersky, M. Sulzmann, and M. Wehr. Type Inference with Constrained Types. TAPOS, 5(1), 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle Scholar
  24. T. Sheard, Z. Benaissa, and E. Pasalic. DSL implementation using staging and monads. In Domain-Specific Languages, pages 81--94, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. D. Syme. Declarative Theorem Proving for Operational Semantics. PhD thesis, University of Cambridge, 1998.Google ScholarGoogle Scholar
  27. D. Syme. ILX: Extending the .NET Common IL for Functional Language Interoperability. Electronic Notes in Theoretical Computer Science, 59(1), 2001.Google ScholarGoogle Scholar
  28. D. Syme and J. Margetson. The F# website, 2006. See http://research.microsoft.com/fsharp/.Google ScholarGoogle Scholar
  29. W. Taha and other contributors. MetaOCaml: a compiled, type-safe multi-stage programming language, 2006. See http://www.metaocaml.org/.Google ScholarGoogle Scholar
  30. W. Taha and T. Sheard. MetaML and multi-stage programming with explicit annotations. Theoretical Computer Science, 248(1--2):211--242, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle Scholar
  32. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  33. M. Wand. The theory of fexprs is trivial. Lisp and Symbolic Computation, 10(3):189--199, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Leveraging .NET meta-programming components from F#: integrated queries and interoperable heterogeneous execution

    Recommendations

    Reviews

    David Ruiz

    .NET is an application framework by Microsoft that is undertaking a major revision with the 3.0 version. LINQ is a Microsoft project that aims to integrate some extensions to the .NET framework to embed languages for queries, sets, and transform operations. F# is a version of ML designed for scripting and strong typing. In this paper, the author shows some examples of meta-programming extensions to F#. He presents two embedded languages: FSQL, to integrate structured query language queries using the LINQ libraries, and FGPU, to provide parallel arrays that can be handled with a graphics processing unit (GPU). He also shows some examples of F# code to build simple queries and one-level nested queries and an example of F# code that implements the game of life with both two-dimensional arrays on the central processing unit and parallel arrays on the GPU. The paper is well written, readable, and gets to the point, but it only illustrates how meta-programming can be useful in the context of ML. The results might be useful to people who need to get a better understanding of meta-programming in the .NET platform, but it does not contribute to the theory of meta-programming. Online Computing Reviews Service

    Access critical reviews of Computing literature here

    Become a reviewer for Computing Reviews.

    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
      ML '06: Proceedings of the 2006 workshop on ML
      September 2006
      102 pages
      ISBN:1595934839
      DOI:10.1145/1159876

      Copyright © 2006 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 September 2006

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • Article

      Acceptance Rates

      Overall Acceptance Rate6of11submissions,55%

      Upcoming Conference

      ICFP '24

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader