Software Architecture

Natural Queries

Programming language research is a quest for expressivity. The aim it enable the expression of complex computations in concise and intuitive ways.

The problem is that conciseness and intuitivity are usually conflicting. Expressivity is enabled by higher-order constructs which are hard to reason about. On one hand, functional languages enable the expression of complex computations concisely, but their intuitivity is low. Integrated query languages can help, though. On the other hand, imperative languages are very intuitive, but their expressivity is low.

Let’s assume you have time series. A sentence like “pick the average of values by intervals of 5 seconds” describes a non-trivial computation. This sentence in a natural language is both intuitive and concise. Dealing with such natural queries is challenging, but feasible. This is what facebook does. An important aspect of the features is that the system gives a feedback to the user about how it understood the query. The user can then rephrase or refine the query.

The same could be integrated into development environments. Instead of expressing computations with functions, developers would first give a shot at a natural description. It would be translated into functional code by the environment. Sample data would be generated to exemplify the query, serving both as immediate feedback for the correctness of the query, and later for unit testing. If the generated code is incorrect, it is refined by the developer. The icing on the cake: the original natural query is kept as a code comment.

2 thoughts on “Natural Queries”

  1. The example you gave would be quite nicely written in Polite

    computer, pick the average of: values by intervals of: 5 seconds.

    But you want more than that, and rightfully so

    I like the idea of sample data which could be generated in some fancy way as Bret Victor shows on his page.

    And one could even generate code in multiple languages such that the programmer would choose the one he is the most confortable with! Or more concise for the problem at hand.

  2. Hmm. Interesting. I am skeptical that the lack of natural language is a barrier to programming. Type systems are hard, programming itself is easy. If Codecademy and related websites have shown something then it is that everybody and their dog can learn programming syntax easily. Graph search’s lack of parentheses is maddening for any query beyond the colloquial “girls who like yoga and sushi.” I very much like your direction of sample data and immediate feedback. That’s the way to go. Add immediate feedback to all our tools. Have you seen Rob Deline’s Stat demo? Are you working on a prototype?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s