© Marcus Denker
TypePlug -- Practical, Pluggable Types
Nik Haldiman
Marcus Denker
Oscar Nierstrasz
University of Bern
Types?
© Marcus Denker
Static typing is Good!
> Programs with failures are rejected
— Reduces errors detected at runtime
> Docume...
© Marcus Denker
Static typing is Evil!
> Exactly all cool programs are rejected
— Reflection?!
> Inconvenience is not at al...
Is it possible to have one’s cake and eat it, too?
© Marcus Denker
Pluggable Types
> Optional: does not change the semantics
> Pluggable: many different ones
— Especially ex...
© Marcus Denker
The Problem
> Large, untyped code-base
> Overhead for using pluggable types is high
— Existing code needs ...
© Marcus Denker
TypePlug
> Pluggable types for Squeak
> Based on sub-method reflection framework
(Demo on Wednesday!)
> Cas...
© Marcus Denker
Non-Nil Type-System
> Declare variables to never be nil
Object subclass: #Line
typedInstanceVariables: ’st...
© Marcus Denker
Non-Nil Type-System
moveHorizontally: anInteger
startPoint := self movePoint: startPoint
horizontally: anI...
© Marcus Denker
Non-Nil Type-System
moveHorizontally: anInteger
startPoint := self movePoint: startPoint
horizontally: anI...
© Marcus Denker
Non-Nil Type-System
movePoint: aPoint horizontally: anInteger
	

 	

 ↑ (aPoint addX: anInteger y: 0) <:no...
© Marcus Denker
The Problem (again)
> Large, untyped code-base
> Overhead for using pluggable types is high
— Existing cod...
© Marcus Denker
Solution
> Only type-check annotated code
> Use type-inference to infer types of non-annotated code
> Expl...
© Marcus Denker
External Type Annotations
> We need to annotate existing code
— Especially libraries and frameworks
— Exam...
© Marcus Denker
Browser
© Marcus Denker
Future Work
> Improve Type-Inference
— Better algorithms
— Explore heuristical type inference (Roeltyper)
...
© Marcus Denker
Conclusion
> TypePlug: Pragmatic framework for Pluggable Types
— Only type-check annotated code
— Use type...
© Marcus Denker
Conclusion
> TypePlug: Pragmatic framework for Pluggable Types
— Only type-check annotated code
— Use type...
TypePlug -- Practical, Pluggable Types
Upcoming SlideShare
Loading in...5
×

TypePlug -- Practical, Pluggable Types

313
-1

Published on

TypePlug -- Practical, Pluggable Types. Nik Haldiman,
Marcus Denker, Oscar Nierstrasz. ESUG 2007, Lugano

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
313
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

TypePlug -- Practical, Pluggable Types

  1. 1. © Marcus Denker TypePlug -- Practical, Pluggable Types Nik Haldiman Marcus Denker Oscar Nierstrasz University of Bern
  2. 2. Types?
  3. 3. © Marcus Denker Static typing is Good! > Programs with failures are rejected — Reduces errors detected at runtime > Documentation > Minor inconvenience, major payoff
  4. 4. © Marcus Denker Static typing is Evil! > Exactly all cool programs are rejected — Reflection?! > Inconvenience is not at all “minor” — Typed programs hard to change + evolve > Only the most trivial errors are detected — False sense of security
  5. 5. Is it possible to have one’s cake and eat it, too?
  6. 6. © Marcus Denker Pluggable Types > Optional: does not change the semantics > Pluggable: many different ones — Especially exotic type-systems > “Type-Systems as Tools” Gilad Bracha, OOPSLA 04: Pluggable Type-Systems
  7. 7. © Marcus Denker The Problem > Large, untyped code-base > Overhead for using pluggable types is high — Existing code needs to be annotated with type information
  8. 8. © Marcus Denker TypePlug > Pluggable types for Squeak > Based on sub-method reflection framework (Demo on Wednesday!) > Case-Studies: — Non-Nil Types — Class Based Types — Confined Types
  9. 9. © Marcus Denker Non-Nil Type-System > Declare variables to never be nil Object subclass: #Line typedInstanceVariables: ’startPoint endPoint <:nonNil:>’ typedClassVariables: ’’ poolDictionaries: '' category: 'Demo' DEMO
  10. 10. © Marcus Denker Non-Nil Type-System moveHorizontally: anInteger startPoint := self movePoint: startPoint horizontally: anInteger. endPoint:=self movePoint: endPoint horizontally: anInteger
  11. 11. © Marcus Denker Non-Nil Type-System moveHorizontally: anInteger startPoint := self movePoint: startPoint horizontally: anInteger. endPoint:=self movePoint: endPoint horizontally: anInteger <- type ’TopType’ of expression is not compatible with type ’nonNil’ of variable ’endPoint’.
  12. 12. © Marcus Denker Non-Nil Type-System movePoint: aPoint horizontally: anInteger ↑ (aPoint addX: anInteger y: 0) <:nonNil :>
  13. 13. © Marcus Denker The Problem (again) > Large, untyped code-base > Overhead for using pluggable types is high — Existing code needs to be annotated with type information
  14. 14. © Marcus Denker Solution > Only type-check annotated code > Use type-inference to infer types of non-annotated code > Explicit type-casts > Allow external annotations for foreign code
  15. 15. © Marcus Denker External Type Annotations > We need to annotate existing code — Especially libraries and frameworks — Example: Object>>#hash is <: nonNil :> > We do not want to change the program code! > Solution: External Type Annotations — Added and modified in the TypesBrowser — Do not change the source — External representation: Type Packages
  16. 16. © Marcus Denker Browser
  17. 17. © Marcus Denker Future Work > Improve Type-Inference — Better algorithms — Explore heuristical type inference (Roeltyper) > Type Checking and Reflection — Use pluggable types to check reflective change
  18. 18. © Marcus Denker Conclusion > TypePlug: Pragmatic framework for Pluggable Types — Only type-check annotated code — Use type-inference — Explicit type-casts — External annotations for foreign code
  19. 19. © Marcus Denker Conclusion > TypePlug: Pragmatic framework for Pluggable Types — Only type-check annotated code — Use type-inference — Explicit type-casts — External annotations for foreign code Questions?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×