(picture)

January 26, 2005

C-omega

(pronounced: "see-Omega") is a really interesting (experimental) programming language from Microsoft's research labs. It tries to do three-and-a-half things, and at first glance succeeds quite nicely at three of them. (The leftover half-a-thing, SQL, is just not worth it anyway).

The three things, then:

  • XML as a first-class language element. XML literals, and by implication native XML-like structures;
  • XPath- and XQuery-like capability, using the sort of functional-programming idioms which Lisp or Haskell weenies dream about: lazy evaluation and mapping across "streams", aka generators;
  • A very natural-looking approach to concurrent programming (which Really Is the next big thing).

The concurrency intro is worth quoting verbatim:

In Cω, methods can be defined as either synchronous or asynchronous. When a synchronous method is called, the caller is blocked until the method returns, as is normal in C#. However, when an asynchronous method is called, there is no result and the caller proceeds immediately without being blocked. Thus from the caller's point of view, an asynchronous method is like a void one, but with the useful extra guarantee of returning immediately. We often refer to asynchronous methods as messages, as they are a one-way communication from caller to receiver (think of posting a letter rather as opposed to asking a question and waiting for an answer during a face-to-face conversation).

By themselves, asynchronous method declarations are not particularly novel. Indeed, .NET already has a widely-used set of library classes which allow any method to be invoked asynchronously (though note that in this standard pattern it is the caller who decides to invoke a method asynchronously, whereas in Cω it is the callee (defining) side which declares a particular method to be
asynchronous). The significant innovation in Cω is the way in which method bodies are defined.

In most languages, including C#, methods in the signature of a class are in bijective correspondence with the code of their implementations -- for each method which is declared, there is a single, distinct definition of what happens when that method is called. In Cω, however, a body may be associated with a set of (synchronous and/or asynchronous) methods. We call such a definition a chord, and a particular method may appear in the header of several chords. The body of a chord can only execute once all the methods in its header have been called.

(, , )