Design and implementation of a programming language for mobile code


Candidato: Lorenzo Bettini

Relatore: Prof. Rocco De Nicola

Controrelatore: Prof. Pierluigi Crescenzi


In this thesis we present X-Klaim, a programming language for distributed applications with mobile code. Mobile code means software which can travel on an heterogeneous network, and that can be executed on the destination site. X-Klaim (eXtended-Klaim is an extension of the kernel  language Klaim (Kernel Language for Agents Interactions and Mobility) which in turn extends Linda, a coordination language for concurrent processes; communication between processes in Linda takes plce by exploiting a shared memory space: the tuple space. A tuple space is a collection of tuples, and a tulpe is a sequence of actual fields (instantiated fields) and formal fields (non instantiated). To select tuples from a tuple space pattern matching is used: two tuples match if they have the same numebr of fields, and every field matches with the corresponding fields (the two fields must have the same type; two actual fields must be equal, while a formal field always matches with a field of the same type). After the matching formal fields become actual, with the same value of the corresponding fields in the other tuple. Linda is insufficient for distributed applications, as tuples are all mixed up in only one tuple space.

Klaim handles multiple distributed tuple space, which are embedded in Nodes in the Net, which you can access to by specifying their locality. We distinguish between physical localities (effettive addresses of nodes in the net) and logical localities (symbolic names through which we can access to nodes). Logical localities are translated in physical localities through evaluation environment, adopting static scoping (by exploiting the environment of the sending nodes) or dynamic scoping (using destination node's environment). In Klaim you can send mobile agents to remote sites, and doing operations on remote tuple spaces. X-Klaim adds to Klaim those features which are typical
of procedural programming languages, making programming easier, but it doesn't add expressivity. Infact the semantic of X-Klaim was given by translation into Klaim, and so what can be programmed in X-Klaim can be programmed in Klaim as well, but it requires less operations.

Java was used to implement the framework with the primitives of Klaim; the implementation is a class library Klava (Klaim in Java), i.e. a package.

A program written in X-Klaim is compiled through the xklaim compiler (implemented with lex and yacc) into a Java program which uses this package. X-Klaim provides primitives to access tuple spaces and for handling mobile agents; it's a Pascal-like language and quite simple, with no need of knowing object oriented programming. You can always use Java (and Klava package) if you want to customize tuple space handling, by deriving from base classes and overriding some methods.
Obviously, as X-Klaim programs are translated in Java, we have the entire integration between these two languages. However X-Klaim stays independent from target language (Java).

in X-Klaim you can handle time outs as well (which were added to Klaim in this thesis); this is useful to avoid to be forever blocked due to low network connections or due to the fact that some tuples are not where we want. In this case we can handle time out by doing some other operations.