1 / 32

Emerald - et OO-språk for distribuerte applikasjoner

Emerald - et OO-språk for distribuerte applikasjoner. Eric Jul OMS Professor II . People. Main Contributions. Distribution: Mobile objects (Eric/Hank) Any object can move at any time. Full on-the-fly object mobility thread mobility heterogeneous mobility

geordi
Download Presentation

Emerald - et OO-språk for distribuerte applikasjoner

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Emerald - et OO-språk for distribuerteapplikasjoner Eric Jul OMS Professor II

  2. People

  3. Main Contributions • Distribution: Mobile objects (Eric/Hank) Anyobjectcanmove at any time. Fullon-the-fly • objectmobility • threadmobility • heterogeneousmobility • Conformitybased type system (Norm/Andrew) Type system basedonconformityprinciple Well-definedsemantics (e.g., NIL makessense!) • Clean OO language (betterthansuccesors?) including uniform object model

  4. History • Developed in Seattle at the University of Washington 1984-1986 • Emerald is green; Emerald City is Seattle • Original UW version: native code and virtual machine for VAX for speed • UBC (University of British Columbia) version: Byte Codes for portability; compiler written in BC Emerald

  5. What does it look like? • In a nutshell: Java with an Algol-like syntax • Heavily inspired by Algol/Simula and Smalltalk • ”Clean” OO language – ”everything” is an object: data, integers, strings, arrays, classes, types as in Smalltalk • Language constructs are NOT objects – for compilability and speed • No pointers: just object & object references

  6. Let’s start with objects Principle: Everything is an object! How to create an object? Classicmethod: X = new someclass Butthisrequiresclasses – let’stryOccam’srazor:

  7. ClasslessObject Construction Objectconstructors: objectseqno var prev: Integer = 0 Integer operation getSeqNo[] prev <- prev +1 returnprev end getSeqno end seqno The above is an executableexpression!

  8. Object Constructors • Execution results in a new object • Execute again – and get yet another object • No class! Want classes?

  9. An Objectthat is a Class objectseqnoclass operation create[] return objectseqno var prev: Integer = 0 Integer operation getSeqNo[] prev <- prev +1 returnprev end getSeqno end seqno end create end seqnoclass

  10. ClasseswithFree Variables objectseqnoclass operation create[] return objectseqno var prev: Integer <- InitSN Integer operation getSeqNo[] prev <- prev +1 returnprev end getSeqno end seqno end create end seqnoclass

  11. ClasseswithParameters objectseqnoclass operation createInit[InitSN: Integer] return objectseqno var prev: Integer <- InitSN Integer operation getSeqNo[] prev <- prev +1 returnprev end getSeqno end seqno end create end seqnoclass

  12. Class done by SyntaticSugaring The followingturnsinto the previous double objectconstructor: classseqno var prev: Integer = 0 Integer operation getSeqNo[] prev <- prev +1 returnprev end getSeqno end seqno

  13. Inheritance by Sugaring const SC <- classseqno var prev: Integer = 0 Integer operation getSeqNo[] prev <- prev +1 returnprev end getSeqno end seqno

  14. Inheritance by Sugaring/Adding const SC2 <- class seqno2 (SC) Integer operation getSeqNo2[] prev <- prev + 2 returnprev end getSeqno2 end seqno2

  15. Inheritance by Sugaring/Overwrite const SC2 <- class seqno2 (SC) Integer operation getSeqNo[] prev <- prev + 2 returnprev end getSeqno end seqno2

  16. Class Operations const SC2 <- class seqno2 (SC) classfunctiongetSuper[] -> [r: Any] r <- SC end getSuper end seqno2

  17. Using a class to create an object Var mySeqNo: type-defined-later mySeqNo <- SC.create[] Classes ARE merelyobjects!

  18. Types Types are abstract descriptions of the operations required of an object (think: Java Interfaces – they are close to identical to types in Emerald). Collection of operation signatures.

  19. Simple Type Example type SeqNoSource Integer getSeqNo[] end SeqNoSource

  20. Using a class to create an object Var mySeqNo: SeqNoSource mySeqNo <- SC.create[]

  21. type BankAccount operation deposit[Integer] operation withdraw[Integer] ->[Integer] functionfetchBalance[] -> [Integer] end BankAccount type DepositOnlyBankAccount functionfetchBalance[] -> [Integer] operation deposit[Integer] end DepositOnlyBankAccount Conformityobject-to-type and type-to-type BankAccountconforms to DepositOnlyBankAccountbecause it support all the require operations – and the parameters alsoconform What is conformity?

  22. Conformity informally An object is said to conform to a type, if • It has the operations specified by the type • For each operation in the type: • The number of parameters is the same in the object as in the type • Each input parameter of the object conforms to the corresponding param of the type • Each output parameter of the type conforms to the corresponding param of the object (contra variant)

  23. Conformity between types Conformity is a mathematical relationship If T is to conform to S: • T must have all the operations required by S • For each operation in T the corresponding operation in S: • in-parameters must conform • out-parameters must conform in opposite order Contravariance: not in Simula nor Eiffel necessary to make semantic sense of programs

  24. Conformity details • Conformity is implicit • No ”implements” as in Java • Operation namesimportant • Parameter names do not matter, just their type • Aritymatters: foo(char) different from foo(char, float)

  25. Conformity more formally • Don’t listen to me: Talk to Andrew Black! • An objectcanconform to manydifferent types • An object has a ”best-fitting” type: the ”largest” of the types that the objectconforms to. Essentially just collect all itsmethods • Conformitydefinedbetween types

  26. Lattice of types • Types form a lattice • Top is type Any end Any • Bottom is Noone(it has ALL operations”) • NILconforms to Noone • NILcanthusbeassigned to any variable! (Read ”MuchAdoAboutNIL.)

  27. Class (withType Added) Const SC <- objectseqnoclass operation create[] -> [r: SeqNoSource] return objectseqno Integer prev=0 int operation getSeqNo[] prev <- prev +1 r <- prev end getSeqno end seqno end create end seqnoclass

  28. Distribution • Sea of objects • Sea is divided into disjunct parts called Nodes • An object is on one and only one Node at a time • Each node is represented by a Node object • Locate X returns the node where X is

  29. Immutable Objects • Immutable objects cannot change state • Examples: The integer 17 • User-defined immutable objects: for example complex numbers • Immutable objects are omnipresent • Types must be immutable to allow static type checking

  30. Types are Immutable Objects Example: arrays varai: Array.of[Integer] ai <- Array.of[Integer].create[] varaai: Array.of[Array.of[Integer]]

  31. Let’s look at the implementation of Array (Switch to code…)

  32. Conclusion Emerald is • clean OO language • fullyintegrated distribution facilities • has fullon-the-flymobility • a well-defined type system Manynovelimplementationtechniques(more talks to come!)

More Related