The Zonnon Project: a .NET Language and Compiler Experiment

The Zonnon Project: a .NET Language and Compiler Experiment

The Zonnon Project: A .NET Language and Compiler Experiment Jürg Gutknecht Vladimir Romanov Eugene Zueff Swiss Fed Inst of Technology Moscow State University Swiss Fed Inst of Technology (ETH) Computer Science Department (ETH) Zürich, Switzerland Moscow, Russia Zürich, Switzerland [email protected] [email protected] [email protected] ABSTRACT Zonnon is a new programming language that combines the style and the virtues of the Pascal family with a number of novel programming concepts and constructs. It covers a wide range of programming models from algorithms and data structures to interoperating active objects in a distributed system. In contrast to popular object-oriented languages, Zonnon propagates a symmetric compositional inheritance model. In this paper, we first give a brief overview of the language and then focus on the implementation of the compiler and builder on top of .NET, with a particular emphasis on the use of the MS Common Compiler Infrastructure (CCI). The Zonnon compiler is an interesting showcase for the .NET interoperability platform because it implements a non-trivial but still “natural” mapping from the language’s intrinsic object model to the underlying CLR. Keywords Oberon, Zonnon, Compiler, Common Compiler Infrastructure (CCI), Integration. 1. INTRODUCTION: THE BRIEF CCI and b) to experiment with evolutionary language HISTORY OF THE PROJECT concepts. The notion of active object was taken from the Active Oberon language [Gut01]. In addition, two This is a technical paper presenting and describing new concurrency mechanisms have been added: an the current state of the Zonnon project. Zonnon is an accompanying communication mechanism based on evolution of the Pascal, Modula, Oberon language syntax-oriented protocols , borrowed from the Active line [Wir88]. Major language concepts and some C# project [Gun04], and an experimental considerations concerning the system architecture “asynchronous” statement execution construct. were presented in a number of papers during the last two years [Gut02, Gut03]. The new language was called Zonnon. It uses a compositional inheritance model. Typically, an object The project emerged from our participation in Projects implements a specified set of definitions, each one 7 and 7+, a collaboration initiative launched by accompanied by a default implementation that is Microsoft Research in 1999 with the goal of aggregated into the object’s state space. The syntax implementing an exemplary set of non-standard of Zonnon is presented in the [Zon05] document. programming languages for the .NET interoperability platform. Our part was Oberon for .NET, an interoperable descendant of Pascal and Modula-2. 2. CURRENT STATE OF THE PROJECT The motivation for continuing the research was The core language is defined and stable but there are twofold: a) to explore the potential of .NET and in still ongoing experiments in the area of concurrency. particular of the new compiler integration technology The current compiler is a well-tested beta version. A Permission to make digital or hard copies of all or part of specifically developed comprehensive Zonnon test this work for personal or classroom use is granted without suite containing more than 1500 Zonnon test cases fee provided that copies are not made or distributed for and covering all language features is used for profit or commercial advantage and that copies bear this systematic testing of the compiler. notice and the full citation on the first page. To copy There are three user environments for the Zonnon otherwise, or republish, to post on servers or to redistribute compiler: command-line, Zonnon Builder and Visual to lists, requires prior specific permission and/or a fee. Studio .NET. We note that, to the best of our .NET Technologies’2005 conference proceedings, knowledge, the Zonnon compiler is the first compiler ISBN 80-86943-01-1 Copyright UNION Agency – Science Press, Plzen, Czech Republic developed outside of Microsoft that is fully 4. ZONNON MAPPINGS TO CLR integrated into Visual Studio. It is currently used in an As mentioned before, the Zonnon object model experimental programming course for junior students differs from the virtual object model proposed by the in Nizhny Novgorod University, Russia [Ger05]. .NET CLR. However, most Zonnon concepts can be mapped rather easily to corresponding CLR notions, 3. BRIEF INTRODUCTION TO with the help of a few minor tricks. The general ZONNON approach taken was trying to make direct use of CLR Being a member of Pascal family of languages and high-level constructs rather than to optimize the thanks to a high degree of compatibility, Zonnon is Zonnon code image. In the following, we will consider immediately familiar to Modula/Oberon programmers. some important mapping examples. Most Oberon programs from the domain of algorithms Zonnon definitions are represented as public and data structures are successfully compiled by the interfaces, and their state variables are mapped to Zonnon compiler after just a few minor modifications. virtual properties. For example, the following sample However, from the perspective of “programming-in- definition the-large”, Zonnon is much more elaborate compared (* Common interface for the random to its predecessors. There are four different kinds of numbers generator *) program units in Zonnon: objects, modules, definition Random; definitions and implementations. The first two are var { get } Next : integer; (* read-only *) program units to be instantiated at runtime, the third procedure Flush; (* reset *) is a compile time unit of abstraction and the fourth is end Random. a unit of composition. Here is a brief characterization: is mapped to the class: Object is a self-contained run-time program entity. It public interface Random { can be instantiated dynamically under program System.Int32 Next { get; } control in arbitrary multiplicity. Compared to Oberon, void Flush(); } the notion of object is conceptually upgraded in Zonnon by the option of adding one or more Implementations are mapped to sealed classes with encapsulated activities that control the intrinsic the same visibility as corresponding definitions. For behavior of the object. example, a possible implementation of the random generator will look like as follows: Module can be considered as a singleton object implementation Random; whose creation is controlled by the system. In var { private } z : integer; addition, a module may act as a container of logically procedure { public, get } Next : integer; connected abstract data types and structural units of const a = 16807; m = 2147483647; the runtime environment. In combination with the q = m div a; r = m mod a; import relation, the module construct is a powerful var g : integer; system structuring tool that is missing in most begin g := a*(z mod q) – r*(z div q); modern object-oriented languages. if g>0 then z := g else z := g+m end; Definition is an abstract view on an object from a return z*(1.0/m) certain perspective or, in other words, an abstract end Next; presentation of one or more of its facets. procedure Flush; begin z := 3.1459 end Flush; Implementation typically provides a possibly partial begin Flush; default implementation of the corresponding end Random. definition. It is a unit of reuse and composition that is aggregated into the state space of an object or The compiler will generate code for this module either at compile time or at runtime. implementation that corresponds to the C# class: public sealed class Random_implem : Random Zonnon also provides a novel object-oriented { concurrency model that follows the metaphor of private System.Int32 z; autonomous active objects interoperating with each System.Int32 Random.Next { get { …; } } other. The model incorporates encapsulated threads void Random.Flush ( ) { z = 3.1459; } of activity serving two purposes: expressing intrinsic public Random_Implem() { Flush(); } } behavior and carrying out formal dialogs. Active C# provides a proof of concept for this concurrency If no implementation is specified for a definition then model. the compiler generates a default implementation with trivial properties. The example below illustrates this module Test; for the Random definition: import Random; (*automatically generated definition companion*) (* both definition and implementation public sealed class Random_default : Random { are imported *) System.Int32 Next_default; var x : object { Random }; System.Int32 Random.Next { (* x’s actual type is any type implementing get { return Next_default; } } } Random *) object R2 implements Random; Zonnon object types actually behave like CLR classes (*alternative random number implementation*) and therefore are mapped to sealed classes with the end R2; same scope of visibility as the object type. In case a begin body is specified in an object type, it is mapped into x := new R1; … an instance constructor as shown here: x := new R2; … object { public } R; public sealed class R { end Test. var x : real; private System.Double x; begin public R ( ) { 5. THE ZONNON COMPILER … x := 777.999; … x = 777.999; … } end R. } Compiler overview The Zonnon compiler is written in C#. It accepts The relationship “object implements definition” is a Zonnon program units and produces conventional fundamental constituent in the Zonnon object model. .NET assemblies containing MSIL code and metadata. It represents an obligation for an object type to The Common Compiler Infrastructure (CCI) provided provide the functionality promised by the definition. by Microsoft

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us