Lecture 10: Bridging Query and Programming Languages

29 October 2010

This is the second of three lectures on integrating domain-specific languages with general-purpose programming languages. In particular, SQL for database queries. This lecture presented LINQ, Language Integrated Query, together with some background on Microsoft’s .NET framework, and the language features added to C# to support LINQ.
Read the rest of this entry »


Lecture 9: Using SQL from Java

26 October 2010

This is the first of three lectures on integrating domain-specific languages with general-purpose programming languages. In particular, SQL for database queries.
Read the rest of this entry »


Lecture 20: Type-Checking for SQLizability

18 March 2010

Review of what LINQ can do in C# to lower the impedance mismatch between general-purpose programming languages and database query languages. Advantages and limitations on this; in particular the possibility of runtime failure, limits of abstraction, and the role of reflection.

One possible route to improving this: introduction of a type and effect system to track behaviour that cannot be represented in SQL. This allows arbitrary use of parametrization and higher-order functions, while providing compile-time guarantees of on-database execution. Outline of proof via a strongly-normalizing rewrite system. Several examples of how this more deeply embeds querying into a functional language, allowing modular construction of code and opening up queries to conventional compiler rewriting as well as SQL database-specific optimisations.

This lecture is based on the work of Ezra Cooper, in particular the following paper:

You can follow his research blog for more on this.

Homework

Please fill out and submit an anonymous feedback questionnaire. Thank you.


Lecture 19: Heterogeneous Metaprogramming in F#

15 March 2010

General overview of metaprogramming, with a range of examples in different languages ranging from C macros through Java reflection to MetaOCaml. Brief summary of the F# language, its history, features, and upcoming release in VS 2010.

Metaprogramming in F#, and how it can be combined with LINQ for database queries, runtime code-generation, and outsourcing computation. How to run Conway’s Life on a GPU without changing your code. This is based on the following paper:

To find out more about this, try also reading the series of articles about accelerating data-parallel code in F# on Tomáš Petrícek’s blog.

Finally, a job ad to work with the F# team.

Links: Slides; F# Developer Network; F# at Microsoft Research; Visual F# Developer Library; Don Syme as Geek of the Week.


Lecture 18: Bridging Query and Programming Languages

11 March 2010

How the LINQ framework for Language-Integrated Query aims to reduce the impedance mismatch between programming languages and query languages.

General background on Microsoft’s .NET Framework: it’s a large platform for program development; as part of this, it has some interesting programming language features. In particular its support for working in multiple languages, exchanging strongly-typed data and code at a high level.

Review of standard SQL-query-as-a-string technique in Java and (almost identically) in C#. Advantages, limitations. What LINQ does to lift some of the limitations. There is convenient SQL-style syntax; but that’s a distraction, the key advance is to connect the semantics of the two language domains. This then brings in type checking, smart IDEs, compiler optimisations, automatic query bundling, abstraction of query constructors, query constructor constructors, user-extensible query libraries, etc. etc.

How this requires (and contributes) a sackful of additional language features, most taken from existing research languages, which themselves have wider application; LINQ as a Trojan horse.

The end result is that a LINQ programmer can write a simple boolean test in C#, or any .NET language, and use it to filter all kinds of data: an array in C#, a table in SQL, or a tree in XML. All being well, LINQ will inspect the semantics of the underlying expression and convert it to the right domain.

Next week: what else it can do, when it doesn’t work, and how that might be fixed.

Link: Slides

What’s in a Name?

During the lecture I referred to the work of Mike Just and others on knowledge-based authentication. There is a discussion of this on the Light Blue Touchpaper security blog, and you can also read the recent published paper and some slides from a recent presentation.

Update: Also appears on BBC News, Telegraph, etc.