JAOO 2002olm1 Early Experience with Language Interoperability Porting the BETA language to Java and.NET Peter Andersen Ole Lehrmann Madsen Center for Pervasive.

Slides:



Advertisements
Similar presentations
pa 1 Porting BETA to ROTOR ROTOR Projects Presentation Day, June by Peter Andersen.
Advertisements

Portability and Safety Mahdi Milani Fard Dec, 2006 Java.
Java security (in a nutshell)
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Lab#1 (14/3/1431h) Introduction To java programming cs425
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
CS 536 Spring Run-time organization Lecture 19.
mbe/pa/olm 1 Integration of BETA with Eclipse eTX presentation Barcelona 2004 Peter Andersen Mads Brøgger Enevoldsen Ole Lehrmann Madsen.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
3/17/2008Prof. Hilfinger CS 164 Lecture 231 Run-time organization Lecture 23.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
The Procedure Abstraction Part I: Basics Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412.
Run time vs. Compile time
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
The environment of the computation Declarations introduce names that denote entities. At execution-time, entities are bound to values or to locations:
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
Lecture 9 Concepts of Programming Languages
Guide To UNIX Using Linux Third Edition
Abstract Data Types and Encapsulation Concepts
1 Software Testing and Quality Assurance Lecture 31 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
Peter Juszczyk CS 492/493 - ISGS. // Is this C# or Java? class TestApp { static void Main() { int counter = 0; counter++; } } The answer is C# - In C#
OOP Languages: Java vs C++
A Free sample background from © 2001 By Default!Slide 1.NET Overview BY: Pinkesh Desai.
Overview of Microsoft.Net and Vb.Net ITSE 2349 Spring 2002 Material from Microsoft.Net an Overview for ACC faculty by Stuart Laughton and Introduction.
Comparison of OO Programming Languages © Jason Voegele, 2003.
Language Systems Chapter FourModern Programming Languages 1.
Programming Languages and Paradigms Object-Oriented Programming.
C++ Programming. Table of Contents History What is C++? Development of C++ Standardized C++ What are the features of C++? What is Object Orientation?
Eric Vogel Software Developer A.J. Boggs & Company.
JVM And CLR Dan Agar April 16, Outline Java and.NET Design Philosophies Overview of Virtual Machines Technical Look at JVM and CLR Comparison of.
The Procedure Abstraction Part I: Basics Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412.
@2011 Mihail L. Sichitiu1 Android Introduction Platform Overview.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Lecture 10 : Introduction to Java Virtual Machine
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Programming Languages and Paradigms Object-Oriented Programming (Part II)
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
1 Comp 104: Operating Systems Concepts Java Development and Run-Time Store Organisation.
CSc 453 Runtime Environments Saumya Debray The University of Arizona Tucson.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
JAVA BASICS Prepared by The Smartpath Information Systems
Basic Semantics Associating meaning with language entities.
Programming Languages by Ravi Sethi Chapter 6: Groupings of Data and Operations.
CSC3315 (Spring 2008)1 CSC 3315 Subprograms Hamid Harroud School of Science and Engineering, Akhawayn University
By: PHANIDEEP NARRA. OVERVIEW Definition Motivation.NET and J2EE Architectures Interoperability Problems Interoperability Technologies Conclusion and.
LANGUAGE SYSTEMS Chapter Four Modern Programming Languages 1.
COMP3190: Principle of Programming Languages
Object-Oriented Programming Chapter Chapter
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Introduction to Programming 1 1 2Introduction to Java.
LECTURE 19 Subroutines and Parameter Passing. ABSTRACTION Recall: Abstraction is the process by which we can hide larger or more complex code fragments.
Memory Management in Java Mr. Gerb Computer Science 4.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Java Interview Questions
Before You Begin Nahla Abuel-ola /WIT.
Names and Attributes Names are a key programming language feature
Lecture 9 Concepts of Programming Languages
More Object-Oriented Programming
Java History, Editions, Version Features
RUN-TIME STORAGE Chuen-Liang Chen Department of Computer Science
Lecture 9 Concepts of Programming Languages
Presentation transcript:

JAOO 2002olm1 Early Experience with Language Interoperability Porting the BETA language to Java and.NET Peter Andersen Ole Lehrmann Madsen Center for Pervasive Computing Aarhus University

JAOO 2002olm2 Content n Background & goals n Virtual machines u The Java- and.NET platforms n BETA n Mapping BETA to Java and.NET n Experience with the platforms n Language interoperability n Demo n Conclusion

JAOO 2002olm3 Background n Modern language implementations: u Virtual machines u Bytecode u Just-in-time compilers u Run-time type information u Verification of code before execution n Main stream platforms u Java virtual machines u Microsoft.NET

JAOO 2002olm4 Main stream OO languages n Java u The one and only language for the Java-platform n C# and VB.Net u The dominant languages for.NET n A family of languages u Java/C#-like languages u And many more

JAOO 2002olm5 Goals I n Implement BETA for u.NET u Java-VM n Investigate the suitability of Java and.NET as platforms for general language implementation

JAOO 2002olm6 Goals II n Investigate language interoperability n Traditional language interoperability for procedural languages u Procedure libraries in different languages u Common calling sequence for procedures n Language interoperability for OO languages u Uses of classes from different languages u Inheritance from classes in different languages u An explicit goal for.NET u No expectations for Java

JAOO 2002olm7 Goals III n Provide a common language for.NET and Java-VM n (Component architecture) u Web services – SOAP n (BETA for PDA’s) u.NET compact framework

JAOO 2002olm8 Challenges I Mapping of BETA to.NET & Java-VM n. NET & Java-VM are typed virtual machines modelled from Java and C# n BETA is much more general n One issue: just finding a mapping

JAOO 2002olm9 Challenges II Language interoperability n BETA should be able to uses classes from other languages n Other languages should be able to use BETA classes (patterns) n BETA should be able to inherit classes from other languages n Other languages should be able to inherit from BETA n The BETA mapping should be ’nice’ when seen from other languages

JAOO 2002olm10 Java/C# language model n A program is a collection of classes n A class defines u Data-items/attributes F an attribute has a type u Methods F a method has arguments and a possible result value n Classes may be nested u Java – real nesting u C# - only a scope mechanism n No nesting of methods n Dynamic exceptions n Concurrency in the form of threads

JAOO 2002olm11 BETA n Class and method unified into the pattern mechanism n General nesting of patterns n INNER instead of super n Genericity in the form of virtual patterns n Multiple return values n Active objects u Coroutines and concurrency u Basis for writing schedulers n No constructors n No dynamic exceptions (yet)

JAOO 2002olm12 Challenges with BETA mapping n Pattern mapping to class and methods n Nested patterns n Nested procedures n Enter-do –exit-semantics n Inner n Virtual patterns – class and procedure n Multiple return values n Leave/restart out of nested method activations n Coroutines and concurrency n Pattern variables n Basic values – signed/unsigned

JAOO 2002olm13 The mapping n Generating code for Java- and.NET corresponds to making a BETA source mapping into Java- and/or C#-source code n In the following the implementation of BETA is shown as a mapping into a Java/C#-like language

JAOO 2002olm14 BETA example Calc: (# set: (# enter V do V  R #); add: (# enter V do R+V  R exit R #); #); 12  C.set; 5  C.add  X

JAOO 2002olm15 Naive mapping into Java/C# Class Calc extends Object { int R; void set(int V) { R = V; }; int add(int V) { R = R + V; return R;} } Calc C = new Calc(); int X; C.set(12); X = C.add(5);

JAOO 2002olm16 Instances of add A: ^C.add; &C.add[]  A[]; 6  A  X More complex mapping needed Possible to create instances of pattern add Creation of an instance of C.add

JAOO 2002olm17 Class add class add extends Object { Calc origin ; int V; void add(Calc org) {origin = org; } void enter(int a) { V = a; } void do() { origin.R = origin.R + V }; int exit() { return origin.R; } } add A; int X; A = new add(C); A.enter(5); A.do() X = A.exit(); 12  C.set; 5  C.add  X

JAOO 2002olm18 Calc with call-add operation Class Calc extends Object { int R; void set(int V) { R = V; }; int add(int V) { add A; A = new add(this); A.enter(V); A.do() return A.exit(); } Calc C = new Calc(); int X; C.set(12); X = C.add(5); We hope the JIT compilers inlines these calls!

JAOO 2002olm19 Calc with call-add & new-add Class Calc extends Object { int R; void set(int V) { R = V; }; int add(int V) {...; return A.exit(); } add add () { return new add(this); } } Calc C = new Calc(); int X; add C.A; C.set(12); X = C.add(5); A = C.add(); Call method for add New method for add

JAOO 2002olm20 General scheme myClass: (#...; f1: (#... #); f2: (#... #); f3: (#... #) #) class myClass extends Object {...; T1 f1(...) {... } // call f1 f1 f1() {... } // new f1 T2 f2(...) {... } // call f2 f2 f2() {... } // new f2 T3 f3(...) {... } // call f3 f3 f3() {... } // new f3 }

JAOO 2002olm21 With language restrictions myClass: class (#...; f1: proc(#... #); f2: proc(#... #); T: class(#... #) #) class myClass extends Object {...; T1 f1(...) {... } // call f1 T2 f2(...) {... } // call f2 T T() {... } // new T }

JAOO 2002olm22 Nested/inner classes in general A: (#... AA: (#... AAA: (#... #) #) class A extends Object {... }; class AA extends Object { A origin, void AA(A org) { origin = org; } } class AAA extends Object { AA origin; void AAA(AA org) { origin = org; } } origin A-object AA-object AAA-object origin

JAOO 2002olm23 Method combination with inner Calc: (#... add: (# enter V do R+V  R; inner exit R #);... #) Xcalc: Calc (# xadd: add (# do R * V  R #) #)

JAOO 2002olm24 Semantics of inner 12  D.set; 5  D.xadd  X add: (# enter V do R+V  R; inner exit R #); xadd: add (# do R * V  R #) 5  D.add.V R + V  R inner R * V  R return D.R  X

JAOO 2002olm25 Class add with inner class add extends Object {... void do() { origin.R = origin.R + V; do_1(); // inner }; void do_1(); } class xadd extends add {... void do_1() { origin.R = origin.R * V; };... }

JAOO 2002olm26 Inner at several levels A: (# do X1; inner; Y1 #); AA: A (# do X2; inner; Y2 #); AAA: AA(# do X3; inner; Y3 #) class A: extends Object { void do() { X1; do_1(); Y1; }; void do_1() } class AA: extends A { void do_1() { X2; do_2(); Y2; }; void do_2() } class AAA: b AA { void do_2() { X3; do_3(); Y3 }; void do_3() }

JAOO 2002olm27 Virtual patterns n BETA has virtual patterns n Virtual patterns used as virtual procedures u Like virtual methods in Java/C# n Virtual patterns used as virtual classes u A mechanism for defining a class parameterized by another class n No counter parts in Java/C# u Proposal on its way for Java

JAOO 2002olm28 Pattern List List: (# element:< Object; insert: (# e: ^element enter e[] do... #);... #) StudentList: List (# element::< Student; #) aPerson[]  L.insert; aStudent[]  L.insert; aPerson[]  S.insert; aStudent[]  S.insert; Illegal Detected by the BETA compiler

JAOO 2002olm29 Virtual class in Java/C# class List extends Object {... void insert(Object e) {... } } class StudentList extends List {... void insert(Object e) { Student e1 = (Student) e;... }

JAOO 2002olm30 Multiple return values Calc: (# getReg: (# exit(R,Rx) #); #); C.getReg  (x,y); A field is added to the class for each return value At the calling site, the exit fields are fetched

JAOO 2002olm31 Leave/restart of nested method calls To be implemented using dynamic exceptions foo: (# do L: (# bar: (# do leave L #); go: (# do restart L #) do (if b then bar else go if) #) #);

JAOO 2002olm32 Remaining issues n Active objects u Coroutines and concurrency n Pattern variables u Classes and methods as first-class values n Basic values – signed/unsigned n And lots of details

JAOO 2002olm33 Compiler organization n Frontend u Parser, abstract syntax trees, semantic checking, semantic analysis, abstract code generation u Platform independent n Backend u Code generation for a specific target u Platform dependent F Sun Solaris F Linux F Windows F Macintosh

JAOO 2002olm34 Compiler reorganization n Frontend u Generate (typed) stack code n Backend u Abstract stack code u Specific targets F.NET F Java-VM

JAOO 2002olm35 Platform issues I n No static link on stack frames u Nested procedures/methods cannot be implemented using the stack n Very rigid typing of class-fields u And method-locals on.NET n Constructor initialization u Impossible to make setups before calling super constructor n General exit out of nested method calls n No support for covariant arguments n No support for covariant return types n Active objects

JAOO 2002olm36 Platform issues II n.NET class references must be fully qualified, including location of binding u Problems with separate compilation n Large number of classes generated due to the generality of BETA patterns u Java class files can only contain one (non-static) class per file u Lots of class files are generated n.NET assemblies can contain any number of classes

JAOO 2002olm37 Platform issues III (minor) n No swap and dup_x1/x2 on.NET n Requirements for fully typed local variables in.NET. u Means that swap cannot be implemented in backend using local variables unless type of two top-of- stack objects are known. n Type of field: super/this class

JAOO 2002olm38 Platform advantages n Well-defined run-time format u More than just a calling convention for procedures n Memory management u Storage allocation u Object format & method activation format u Garbage collection n Efficient code generation n We will have BETA for all Java- and.NET platforms n Can this be utilized efficiently? u If simple and direct mapping – yes u If complex mapping – no? u Inlining may help F Can rely on generating methods that the JIT inlines

JAOO 2002olm39 Language interoperability I n Java/C# class inherited from BETA u Straight forward u Since name & type-based, F just specify the methods you will use u Simpler than for COM F COM uses offsets F All preceding methods must be declared n BETA pattern inherited from Java/C# class u Also straight forward u Issues with default constructor F BETA object requires surrounding object (origin)

JAOO 2002olm40 Language interoperability II n Issues u Libraries and frameworks in Java/C# u Java-string, C#-String, BETA-text F Automatic coercion implemented u Overloading u Constructors n External class interface u Interface syntax needed – currently clumsy u External name & location u Automatic include of interface files F.NET assemblies F Java class-files

JAOO 2002olm41 Demo n Inheritance in BETA of external class u Java Applet n Inheritance of BETA pattern in Java and C# n Implementation of program using Google web-service u In C# and Java n Debugging of Google search in Visual Studio.Net

JAOO 2002olm42 Conclusion n Not trivial to map all parts of BETA n We still need to measure efficiency n Generation of bytecode: straightforward u Java issue: no standard assembler n Generation of type information: a lot of work n No real problems in supporting both platforms n Use of Visual Studio to edit and debug BETA programs u Impressive u Source level debugging, breakpoints, object-inspection,...

JAOO 2002olm43 Language interoperability n. NET/C#: seems to work as promised u Class instance u Inheritance u Visual Studio n Java: works well too – to our surprise u Class instance u Inheritance u Has not found any (free) SDE’s that work as well as Visual Studio (which is expensive, but stand alone graphical debugger part of free.NET framework) n It seems realistic to mix libraries and frameworks from different languages n Easier to introduce new languages

JAOO 2002olm44 BETA Language changes n Constructors n Restricting a pattern as class or method n Add properties as in C# n Issue with super/inner call sequencing n Overloading?

JAOO 2002olm45 Status n Large subset of BETA has been implemented n To be done u General leave/restart u Active objects u Pattern variables u Lots of details u Porting BETA libraries and frameworks to Java and.NET

JAOO 2002olm46 Acknowledgements n Peter Andersen - n Ole Lehrmann Madsen - n Project in u Center for Pervasive Computing u n Supported by u Microsoft Denmark u Sun Microsystems Denmark n Ideas borrowed from u Kresten Krab Thorup u Henry Michael Lassen u Kim Falk Jørgensen