Saturday, August 05, 2006

Some interesting aspects of programming : Multi-stage programming

The basic need for "multi-stage programming" arises of the following situation. Say you need to write a program whose result won't be a single number, but rather a computation, for instance a function that double its input f : R --> R , x --> 2*x, or anything that might be represented in some langage of your choice called L. The question is : given L, how do we construct a langage L* which can output some L in a consistent way. One can thinks of generics in dotnet2.0 or Java 1.5 as a particular case of multi-stage programming. Generics are L* functions verifying L syntax, with an extra variable representing a type, and they eventually produce code in L for that type. L* naturally inherits a typesytem fostered by L typesystem. For instance some L* function producing a function outputing a real number cannot be composed with another L* function having strings as an input. Thus an expression that produces code for treating integers can be typed as being such. L* is a first-order langage with respect to L, and its types are expressed using first-order logic to create first-order data types of L. A very nice introduction to a multistage C# or java can be found here. As everyone gets more accustomed to computers, there has been a huge push to get more than just static data, but also exchange programmatic-like structures, like dynamic web pages. There programmers need to have multistaged programming capacities. This explains a lot of the popularity for javascript, along with its universal runtime platform, as its L* can accept almost everything, being a very weakly typed system.


Post a Comment

<< Home