Oberon for .NET Jürg Gutknecht, ETH Zürich, PDC 2001

Project 7/7+ Launched and Sponsored by Microsoft Research

http://www.oberon.ethz.ch/oberon.net/ The Pascal Family: History of ETH Programming Languages

“ 1960 Algol: Procedures & principle of locality, structured programming “ 1970 Pascal: Data structures, p-code, algorithms & data structures “ 1980 -2: Modules, interfaces, Lilith & m-code, programming-in-the-large “ 1990 Oberon: data type extension, object- oriented-programming “ 2000 Active Oberon for .NET new object model, interoperability, component programming The Pascal Family: History of ETH Programming Languages

“ 1960 Algol: Procedures & principle of locality, structured programming “ 1970 Pascal: Data structures, p-code, algorithms & data structures “ 1980 Modula-2: Modules, interfaces, Lilith & m-code, programming-in-the-large “ 1990 Oberon: data type extension, object- oriented-programming “ 2000 Active Oberon for .NET new object model, interoperability, component programming The Pascal Family: History of ETH Programming Languages

“ 1960 Algol: Procedures & principle of locality, structured programming “ 1970 Pascal: Data structures, p-code, algorithms & data structures “ 1980 Modula-2: Modules, interfaces, Lilith & m-code, programming-in-the-large “ 1990 Oberon: data type extension, object- oriented-programming “ 2000 Active Oberon for .NET new object model, interoperability, component programming Project Opportunities for ETH

“ Use .NET as implementation platform “ Offer academic language to wide audience “ Explore language interoperability “ Provide Pascal-line teaching alternative “ Use .NET as a teaching subject “ Interoperability framework “ Compiler/runtime technology “ Use .NET as language research platform “ Experiment with new paradigms & models Project Opportunities for ETH

“ Use .NET as implementation platform “ Offer academic language to wide audience “ Explore language interoperability “ Provide Pascal-line teaching alternative “ Use .NET as a teaching subject “ Interoperability framework “ Compiler/runtime technology “ Use .NET as language research platform “ Experiment with new paradigms & models Project Opportunities for ETH

“ Use .NET as implementation platform “ Offer academic language to wide audience In “ Explore language finteroperabilityus rom e a W t E “ Provide Pascal-line teachingS alternativeTH 20 01 “ Use .NET as a teaching subject/2 “ Interoperability framework “ Compiler/runtime technology “ Use .NET as language research platform “ Experiment with new paradigms & models Project Opportunities for ETH

“ Use .NET as implementation platform “ Offer academic language to wide audience “ Explore language interoperability “ Provide Pascal-line teaching alternative “ Use .NET as a teaching subject “ Interoperability framework “ Compiler/runtime technology “ Use .NET as language research platform “ Experiment with new paradigms & models Active Oberon The New Object Model

“ Modules “ Conceptual combination of namespace and system-managed object “ Active Objects “ Conceptual integration of behavior into (sharable) objects “ Definitions “ Abstract interface/class aggregates Active Oberon The New Object Model

“ Modules “ Conceptual combination of namespace and system-managed object “ Active Objects “ Conceptual integration of behavior into (sharable) objects “ Definitions “ Abstract interface/class aggregates Sample Module MODULE RandomNumbers; VAR z: LONGINT; (*global variable*) PROCEDURE Next*(): REAL; Interface CONST a = 16807; m = 2147483647; q = m DIV a; r = m MOD a; VAR g: LONGINT; BEGIN Implementation g := a*(z MOD q) - r*(z DIV q); IF g > 0 THEN z := g ELSE z := g + m END; RETURN z*(1.0/m) (*value*) END Next; BEGIN z := 31459 END RandomNumbers. Initialization Active Oberon The New Object Model rful “ Modules owe ool e p g t vid urin “ ConceptualPro combinationuct of namespace str tem and system-managedsys object “ Active Objects “ Conceptual integration of behavior into (sharable) objects “ Definitions “ Abstract interface/class aggregates Active Oberon The New Object Model

“ Modules “ Conceptual combination of namespace and system-managed object “ Active Objects “ Conceptual integration of behavior into (sharable) objects “ Definitions “ Abstract interface/class aggregates Sample Active Object Sprite = OBJECT VAR shape: Figure; X, Y, nextX, nextY: REAL; PROCEDURE Step (VAR X, Y: INTEGER); BEGIN ... Law of movement END Step; PROCEDURE NEW (s: Figure; x, y: INTEGER); BEGIN Initialization shape := s; X := x; Y := y; Draw(shape, X, Y) END NEW; Behavior run as BEGIN { ACTIVE } separate thread LOOP Step(nextX, nextY); Erase(shape, X, Y); X := newX; Y := newY; Draw(shape, X, Y) END END Sprite; The New Computing Model active establishing c y y object access s shared y y AWAITy c z resourceaccess s s is s blocked z´s z x thread s call y s s active x´s object thread x Active Oberon The New Object Model

“ Modules “ Conceptual combination of namespace and system-managed object ew “ Active Objects e „n s th del“ res mo “ Conceptual integrationExp ing of behavior put into (sharable)co objectsm “ Definitions “ Abstract interface/class aggregates Active Oberon The New Object Model

“ Modules “ Conceptual combination of namespace and system-managed object “ Active Objects “ Conceptual integration of behavior into (sharable) objects “ Definitions “ Abstract interface/class aggregates Design Patterns Co nt aine Client Interface r Client Truck Delegation Truck le hic this! Ve Container Vehicle

Client Helper class Base class Interface

this? Delegation Truck

Vehicle Container or this? Helper class Base class Active Oberon The New Object Model

“ Modules “ Conceptual combination of namespace and system-managed object “ Active Objects “ Conceptual integration of behavior into (sharable) objects ples “ Definitions inci pr on nify acti “ Abstract interface/classU bstr aggregates of a .NET Compiler A Research Platform

“ Mapping Active Oberon → .NET “ Mapping statements “ Mapping object model

“ Modules

“ Active Objects

“ Definitions “ Interfacing with .NET “ Based on Reflection & Reflection Emit API “ Based on parse Tree API .NET Compiler A Research Platform

“ Mapping Active Oberon → .NET “ Mapping statements “ Mapping object model

“ Modules

“ Active Objects

“ Definitions “ Interfacing with .NET “ Based on Reflection & Reflection Emit API “ Based on parse Tree API assembly M M A

PE X sealed class module version Y lock class static constructor M sealed class for module initialization .NET Compiler A Research Platform

“ Mapping Active Oberon → .NET “ Mapping statements “ Mapping object model

“ Modules

“ Active Objects

“ Definitions “ Interfacing with .NET “ Based on Reflection & Reflection Emit API “ Based on parse Tree API .NET Compiler A Research Platform

“ Mapping Active Oberon → .NET “ Mapping statements “ Mapping object model

“ Modules

“ Active Objects

“ Definitions “ Interfacing with .NET “ Based on Reflection & Reflection Emit API “ Based on parse Tree API DEFINITION D; VAR x: T; PROCEDURE f (y: T); Active VAR z: T; BEGIN x := y ; z := x Oberon END f; PROCEDURE { ABSTRACT } g(): T; END D; TYPE A = OBJECT IMPLEMENTS D; C# PROCEDURE g (y: T) IMPLEMENTS D.g; VAR z: T; BEGINpublic z := x; interface x := y ID { END g; int x { get; set; } END A; void f(int y); /* implemented by SD.f */ void g(int y); } public class SD { public static void f(D me, int y) { int z; me.x = y; z = me.x; } }

sealed class A: ID { int D_x; public void g(int y) { int z; z = x; x = y; } public void f(int y) { SD.f(this, y); } /* delegation */ public int x { get { return D_x; } set { D_x = value; }}} .NET Compiler A Research Platform

“ Mapping Active Oberon → .NET “ Mapping statements “ Mapping object model

“ Modules

“ Active Objects

“ Definitions “ Interfacing with .NET “ Based on Reflection & Reflection Emit API “ Based on parse Tree API .NET Compiler A Research Platform

“ Mapping Active Oberon → .NET “ Mapping statements “ Mapping object model

“ Modules

“ Active Objects

“ Definitions “ Interfacing with .NET “ Based on Reflection & Reflection Emit API “ Based on parse Tree API .NET as Compiler Research Platform gy nolo tech Comprehensive piler com parse tree API New Active Oberon compiler MSIL code

Active Oberon source code Serialization factored out .NET Compiler A Research Platform

“ Mapping Active Oberon → .NET “ Mapping statements “ Mapping object model

“ Modules

“ Active Objects

“ Definitions “ Interfacing with .NET “ Based on Reflection & Reflection Emit API “ Based on parse Tree API