Comega

Cω is a research programming language. It can be written as Cw or the "Comega language". It is a free extension to the C# programming language, developed by the WebData team in Microsoft SQL Server in collaboration with Microsoft Research in the UK and Redmond. It was formerly known as the codenames "X#" (X Sharp) and "Xen". It was renamed Cω after Polyphonic C#, another research language based on Join calculus, was integrated into it.

Cω attempts to make data stores (such as databases and XML documents) accessible with the same ease and type safety as traditional types like strings and arrays. Many of these ideas were inherited from an earlier incubation project within the WebData XML team called X# and Xen. Cω also includes new constructs to support concurrent programming; these features were largely derived from the earlier Polyphonic C# project.

The goal of the Cω type system is to bridge the gap between Relational, Object, and XML data access by creating a type system that is a combination of all three data models. Instead of adding built-in XML or relation types to the C# language, the approach favored by the Cω type system has been to add certain general changes to the C# type system that make it more conducive for programming against both structured relational data and semi-structured XML data.

A number of the changes to C# made in Cω make it more conducive for programming against strongly typed XML, specifically XML constrained using W3C XML Schema. Several concepts from XML and XML Schema have analogous features in Cω. Concepts such as document order, the distinction between elements and attributes, having multiple fields with the same name but different values, and content models that specify a choice of types for a given field exist in Cω. A number of these concepts are handled in traditional Object<->XML mapping technologies, but it is often with awkwardness. Cω aims to make programming against strongly typed XML as natural as programming against arrays or strings in traditional programming languages.

468X60 Banner Ad - March Madness

Well, it's not really a new language, it's rather a collection of new language features. Summarized in one sentence, Cw is focusing mainly on briding the gap between various data models. (formerly known as X# or Xen), including the relational model, the object model and XML. The overall idea is to extend C# with language constructs that make it easier to program against structured relation data and semi-structured XML data. But there is more than just this:

  • Streams, iterator functions and apply-to-all-expressions allow you to do similar things as with sequences in XPath and XQuery. In fact, part of this has already been realized in C# v2.0 with generic collections. As the matter in fact, one of the differences is that C# is now aware of the concept of streams (that are declared using *, which looks somewhat like C/C++ pointers at first sight). Multiple streams cannot be embedded but will be flattened into one stream.
  • Content classes are in fact declared as structs and are the C#-language equivalent for DTDs in the XML space. The idea is to declare "content" that is semi-structured based on a struct definition that is extended with *, + and ? "flags" that work in a similar fashion as these operators in regular expressions (optional, one or more, zero or one). By declaring such a type, you can use XML directly in the language to declare an instance of that type and to perform various operations on it (this feature of embedding XML in code is also referred to as XML literals in Cw).
  • Nullable types introduces kind of a ternary logic in the language, allowing value types to be null too (I call it ternary because of the sample of having a bool? type - no the ? is not a typo - that can have values true, false and null). This means that a null reference can be propagated to its properties (e.g. retrieving the length of a string which is set to null returns null too).
  • Choce types are the equivalent of the XSD xs:choice element in the XML world. Basically it's very similar to union types in C/C++ where the start address of more than one variable (type) is the same (thus values that are projected on the same memory location are sitting "on top of each other"). Because of the static checks of the compiler, you can assign to the choice type without referencing the internal type (e.g. choice{int; string;} x = 1; will set the int value whereas choice{int; string; } y = "bart" will set the string value).
  • Anonymous structs are the same as xs:sequence declarations in XSD. Basically it just means that you can declare a struct that has various types in it and you can just assign to it without having to use field names or whatsoever (e.g. struct {string; string; double price} allows you to instantiate an instance using new {"Duvel", "Beer", 2.50 } and to take advantage of it by using indexers and properties for the named fields).
  • Built-in query operators for XPath. As you can use XML inside the Cw language directly, you need a way to query the "variables" too. In order to do so, the 'dot' operator plays the same role as XPath queries (Products.Product.Price maps to '/Products/Product/Price') and of course this is strongly-typed. However, there is more. When using the * operator you retrieve a stream (same operator to declare and use streams). This way you can get all the products by using Products.Product.*, which is a stream container that you can iterate over and so on. Last but not least the [...] notation allows you to perform selections on the objects, returning a stream with the found elements.
  • Built-in query operators for SQL. To bridge the gap between object-oriented design and relational databases, Cw supports database objects that represent a relational database on some server somewhere. Queries can then be done (that is, after importing the schema) by using built-in operators such as select. The big advantage of this is the static typing at compile time and the fact that you can avoid classic O/R mapping tools (cf. O/R tools, ObjectSpaces, etc). The syntax is the same as SQL (select ... from ... where ... order by ... group by ... having ..., support for joins etc) but it's using classic operators such as &&, ||, ! to create logical expressions.
  • SQL DML statements in Cw. As you have query statements, you also have DML statements (i.e. update, insert, delete) in Cw, also in a strongly typed fashion. There's also built-in transaction support using the keywords transact, commit and rollback associated with a database object (looks somewhat like try...catch...finally or using block structures).
  • Concurrency is also tightly integrated in Cw. That means you'll find the notion of synchronous and asynchronous methods (async keyword, allows you to create thread without using a thread library or async constructions from the .NET Framework directly). Beside of that, there's the notion of a chord. Explained very briefly (in more detail later on in a future post) a chord is a list of methods that is associated with a method declaration. Semantically, a chord tells the system that the method in question can only be executed if all the chords have been called previously. By using this mechanism, synchronisation issues can be solved rather declaratively than by using classic constructs like semaphores. In fact, this is the field of a subset of Cw (in fact it's the other way around, Cw is a merge of various projects) called Polyphonic C#.

blogspot stats