54
Martin is getting the projector to work with his laptop.

Classes in the Mist

  • Upload
    esug

  • View
    1.761

  • Download
    0

Embed Size (px)

DESCRIPTION

A non-traditional Smalltalk gets classy

Citation preview

Page 1: Classes in the Mist

Martin is gettingthe projector

to workwith his laptop.

Page 2: Classes in the Mist

Classes in the MistA Non-Traditional Smalltalk Gets ClassyMartin McClure

Page 3: Classes in the Mist

There is no “I”in “Team”

Page 4: Classes in the Mist

There is no “C”in “Smalltalk”

Page 5: Classes in the Mist

Mist•Open-source (MIT)•mist-project.org (see previous videos)•Github

Page 6: Classes in the Mist

Status(overview)

Page 7: Classes in the Mist

Status(overview)

Why Now?

Page 8: Classes in the Mist

Values•Self-sufficiency

•Simplicity

•Consistency

•Speed

•Craziness

Page 9: Classes in the Mist

Self-Sufficiency

Page 10: Classes in the Mist

Minimize Dependencies

Page 11: Classes in the Mist

Minimize Dependencies

Maximize Interoperability

Page 12: Classes in the Mist

Simplicity

Page 13: Classes in the Mist

Consistency

Page 14: Classes in the Mist

Speed

Page 15: Classes in the Mist

Craziness

Page 16: Classes in the Mist

“If you aren't doing some things that are crazy, you're

doing the wrong things”Larry Page, Google CEO

Page 17: Classes in the Mist

Values•Self-sufficiency

•Simplicity

•Consistency

•Speed

•Craziness

Page 18: Classes in the Mist

Strategies•Spend memory freely

•Start simple

•Broad solutions

•Unconventional first

•Go for the 80/20

Page 19: Classes in the Mist

Implementation

Page 20: Classes in the Mist

Initial TargetX86_64 Linux

Page 21: Classes in the Mist

Mist compiles to

Fogcompiles to

machine code

Page 22: Classes in the Mist

Primitives are written directly in

Fog

Page 23: Classes in the Mist

Executable image

Page 24: Classes in the Mist

Fully Dynamic

Page 25: Classes in the Mist

Object Headers

Page 26: Classes in the Mist

Object Headers

NO

Page 27: Classes in the Mist

Object HeadersInstance Variables

Page 28: Classes in the Mist

Memory Management

Page 29: Classes in the Mist
Page 30: Classes in the Mist

Garbage Collection

     gcMark      isGcMarked           ifFalse: [isGcMarked := true.                    self allReferencesDo: 

[:each | each gcMark]]    gcSweep      isGcMarked        ifTrue: [isGcMarked := false]        ifFalse: [|size|                  size := self physicalSize.                  class := FreeSpace.                  self physicalSize: size.                  TheObjectManager                     add: self toFreeListForSize: size]

Page 31: Classes in the Mist

Tail Call Elimination

Page 32: Classes in the Mist

Loop using recursion

SmallInteger  to: limit byPositive: increment do: aBlock    | nextIndex |    aBlock value: self.    nextIndex := self + increment.    ^ nextIndex > limit        ifFalse: [nextIndex                     to: limit                     byPositive: increment                     do: aBlock].

Page 33: Classes in the Mist

Loop with Tail Call Elimination

SmallInteger  to: limit byPositive: increment do: aBlock    | nextIndex |    aBlock value: self.    nextIndex := self + increment.    ^ nextIndex > limit        ifFalse: [nextIndex                     to: limit                     byPositive: increment                     do: aBlock].

Page 34: Classes in the Mist

Loop with Tail Call Elimination

False  ifFalse: aBlock    ^ aBlock value.

<this block's closure class>  value    ^ nextIndex         to: limit         byPositive: increment         do: aBlock.

Page 35: Classes in the Mist

Language Features

Page 36: Classes in the Mist

Traits

Page 37: Classes in the Mist

Stateful Traits

Name:  IdentityHash

Instance Variables:  identityHash

Methods:  identityHash    identityhash == nil      ifTrue: [identityHash := Random integer].  ^identityHash

Page 38: Classes in the Mist

Indexed instvars as a trait

Page 39: Classes in the Mist

Do youneed both concepts?

Page 40: Classes in the Mist

Classes Compose...

Page 41: Classes in the Mist

...but Do Not Inherit

Page 42: Classes in the Mist

Methods● Compose as in traits● Rename or omit on conflict● Can declare private● No super send● Special behavior of self send

Page 43: Classes in the Mist

Instvars● Private to defining class● Name conflicts impossible● Indexed instvars – some fussing needed

Page 44: Classes in the Mist

Abstract Class● #basicNew not understood● “class” instvar not present

Page 45: Classes in the Mist

Concrete Class● Compose one concrete class

...and only one

Page 46: Classes in the Mist

ClassComposition

vsObject Composition

Page 47: Classes in the Mist

Modules

Page 48: Classes in the Mist

Variables● Args and temps● Instance variables● Module variables

– Class names● Class variables?

– Compile-time constants

Page 49: Classes in the Mist

Safety● Privacy● Teams

Page 50: Classes in the Mist

Massively Single-threaded

Page 51: Classes in the Mist

No String Literals

Page 52: Classes in the Mist

Stream Literals

'Name: [name] Address: [address]'

Page 53: Classes in the Mist

Status(detailed)

Page 54: Classes in the Mist

Classes in the MistA Non-Traditional Smalltalk Gets ClassyMartin McClure