newspeak: evolving smalltalk for the age of the net

62
Newspeak: Evolving Smalltalk for the Age of the Net Gilad Bracha Distinguished Engineer Cadence Design Systems

Upload: esug

Post on 20-May-2015

869 views

Category:

Technology


0 download

DESCRIPTION

Newspeak: Evolving Smalltalk for the Age of the Net. Gilad Bracha. ESUG 2008, Amsterdam

TRANSCRIPT

Page 1: Newspeak: Evolving Smalltalk for the Age of the Net

Newspeak:Evolving Smalltalk for the Age of the Net

Gilad BrachaDistinguished Engineer

Cadence Design Systems

Page 2: Newspeak: Evolving Smalltalk for the Age of the Net

Genealogy of Newspeak

Smalltalk

Newspeak

Self Beta

Scala

Page 3: Newspeak: Evolving Smalltalk for the Age of the Net

Goals and Principles

Goals

Modularity

Security

Interoperability

Design Principle: Message based Programming

Page 4: Newspeak: Evolving Smalltalk for the Age of the Net

Message-based Programming

Smalltalk should have been message-oriented - Alan Kay

Page 5: Newspeak: Evolving Smalltalk for the Age of the Net

Every run time operation is a message send.

Message-based Programming

Page 6: Newspeak: Evolving Smalltalk for the Age of the Net

In Smalltalk

t := Array new: n.

^t

Page 7: Newspeak: Evolving Smalltalk for the Age of the Net

In Smalltalk

t := Array new: n.

^t

Page 8: Newspeak: Evolving Smalltalk for the Age of the Net

In Smalltalk

t := Array new: n.

^t

assignment

Page 9: Newspeak: Evolving Smalltalk for the Age of the Net

In Smalltalk

t := Array new: n.

^t

Globalassignment

Page 10: Newspeak: Evolving Smalltalk for the Age of the Net

In Smalltalk

t := Array new: n.

^t

Global

temp/arg

assignment

Page 11: Newspeak: Evolving Smalltalk for the Age of the Net

In Smalltalk

t := Array new: n.

^t

Global

inst var

temp/arg

assignment

Page 12: Newspeak: Evolving Smalltalk for the Age of the Net

In Smalltalk, using messages

self t: (self Array new: (self n)).

^self t

Page 13: Newspeak: Evolving Smalltalk for the Age of the Net

In Smalltalk, using messages

self t: (self Array new: (self n)).

^self t

Page 14: Newspeak: Evolving Smalltalk for the Age of the Net

Implicit receivers

t: (Array new: n).

^t

Page 15: Newspeak: Evolving Smalltalk for the Age of the Net

In Newspeak

t:: Array new: n.

^t

Page 16: Newspeak: Evolving Smalltalk for the Age of the Net

In Smalltalk, using messages

self t: (self Array new: (self n)).

^self t

Page 17: Newspeak: Evolving Smalltalk for the Age of the Net

In Smalltalk

t := Array new: n.

^t

inst var

Page 18: Newspeak: Evolving Smalltalk for the Age of the Net

Representation Independence

No code depends on our choice of storage representation

Clients never depended on it in Smalltalk

Now subclasses don’t depend on it either

Even the class itself doesn’t

Page 19: Newspeak: Evolving Smalltalk for the Age of the Net

In Smalltalk

t := Array new: n.

^t

Global

Page 20: Newspeak: Evolving Smalltalk for the Age of the Net

No Static

No globals, no class variables, no pool variables of any kind; no class instance variables

Page 21: Newspeak: Evolving Smalltalk for the Age of the Net

Good for

Distribution

Re-entrancy

Testing

Startup

Memory management

Security

No Static

Page 22: Newspeak: Evolving Smalltalk for the Age of the Net

Goals

Modularity

Security

Interoperability

Page 23: Newspeak: Evolving Smalltalk for the Age of the Net

Object-capability model (Miller06)

Object reachability defines authority

No static state

No Ambient Authority

Objects as Capabilities

Page 24: Newspeak: Evolving Smalltalk for the Age of the Net

Object-capability model (Miller06)

Object reachability defines authority

No static state

No Ambient Authority

Access control

Objects as Capabilities

Page 25: Newspeak: Evolving Smalltalk for the Age of the Net

Access Control

In Smalltalk, the only means of data hiding are instance variables & blocks

Messages are always public

If everything is a message send, everything is public

Public, protected and private messages

Page 26: Newspeak: Evolving Smalltalk for the Age of the Net

Mirror based Reflection

Mirrors act as capabilities for reflection

Availability of reflection can be controlled

For security

For deployment

Page 27: Newspeak: Evolving Smalltalk for the Age of the Net

Where does the state go?

No Static State

Page 28: Newspeak: Evolving Smalltalk for the Age of the Net

No Static State

How do different objects conveniently share state?

Page 29: Newspeak: Evolving Smalltalk for the Age of the Net

No Static State

How do different objects conveniently share state?

Via shared lexical scope

Page 30: Newspeak: Evolving Smalltalk for the Age of the Net

Nested Classes

Nested as in Beta, not as in Java

Great for Modeling

Natural Modularity Solution

Page 31: Newspeak: Evolving Smalltalk for the Age of the Net

Goals

Modularity

Security

Interoperability

Page 32: Newspeak: Evolving Smalltalk for the Age of the Net

No References to Classes

Always use accessors

Classes are first class objects

Classes are always virtual

Classes are always mixins

Class hierarchy inheritance

Page 33: Newspeak: Evolving Smalltalk for the Age of the Net

External Dependencies are Explicit

Module definition = Class not nested within another class

No access to surrounding namespace

All names locally declared or inherited

Page 34: Newspeak: Evolving Smalltalk for the Age of the Net

Modules are Sandboxes

Factory method parameters are objects/capabilities that determine per-module sandbox

Page 35: Newspeak: Evolving Smalltalk for the Age of the Net

Side by Side

Module definitions are instantiated into stateful objects known as modules

Easy to create multiple instances, with different parameters

Page 36: Newspeak: Evolving Smalltalk for the Age of the Net

Modules are Re-entrant

Module definitions are deeply immutable

Modules cannot step on each other’s state

Page 37: Newspeak: Evolving Smalltalk for the Age of the Net

Multiple Implementations

Modules are objects, accessed via their protocol

Different implementations can co-exist

Page 38: Newspeak: Evolving Smalltalk for the Age of the Net

Module definitions are objects

Instantiate module in deeply immutable object literal’s main: method

Deployment amounts to object serialization

Start up app by deserializing and invoking main:

Deployment

Page 39: Newspeak: Evolving Smalltalk for the Age of the Net

Goals

Modularity

Security

Interoperability

Page 40: Newspeak: Evolving Smalltalk for the Age of the Net

Smalltalk has Primitive Features

Alberto Salguero

primFree: address

<primitive: 'primFree'

error: errorCode

module: 'IA32ABI'>

^self primitiveFailed

Page 41: Newspeak: Evolving Smalltalk for the Age of the Net

Smalltalk has Primitive Features

Alberto Salguero

primFree: address

<primitive: 'primFree'

error: errorCode

module: 'IA32ABI'>

^self primitiveFailed

Page 42: Newspeak: Evolving Smalltalk for the Age of the Net

Smalltalk has Primitive Features

primFree: address

<primitive: 'primFree'

error: errorCode

module: 'IA32ABI'>

^self primitiveFailed

Are you proud when you explain this to a

non-Smalltalker?

Page 43: Newspeak: Evolving Smalltalk for the Age of the Net

Smalltalk has Primitive Features

primFree: address

<primitive: 'primFree'

error: errorCode

module: 'IA32ABI'>

^self primitiveFailed

What object is the receiver?

Page 44: Newspeak: Evolving Smalltalk for the Age of the Net

Nothing Primitive about Newspeak

There is no “primitive” construct in Newspeak - contradicts message-based philosophy

Instead, you send a message to the VM, as reified via a VM mirror

VM mirror behavior should be standardized

Page 45: Newspeak: Evolving Smalltalk for the Age of the Net

Primitives & Foreign calls

In many languages, primitives are just foreign calls

These notions are distinct

Primitives do not need to worry about marshaling

Assumption that VM is in another language is inappropriate

Page 46: Newspeak: Evolving Smalltalk for the Age of the Net

Primitives & Foreign calls

In most Smalltalks, foreign calls are variations of primitives

They therefore inherit

Ugliness

Lack of portability

Often an afterthought

Page 47: Newspeak: Evolving Smalltalk for the Age of the Net

Aliens

In Newspeak, calling out is achieved by sending messages to alien objects

You can send blocks as arguments to implement call backs

Different alien libraries can support different languages

Page 48: Newspeak: Evolving Smalltalk for the Age of the Net

Portable Native GUI

Page 49: Newspeak: Evolving Smalltalk for the Age of the Net

The Age of the NetCloud Computing

Page 50: Newspeak: Evolving Smalltalk for the Age of the Net

The Age of the NetCloud Computing

Page 51: Newspeak: Evolving Smalltalk for the Age of the Net

The Age of the Net

Cloud Computing

Software delivery and maintenance over the net

Javascript is the assembly language of the internet, browser is the OS

Page 52: Newspeak: Evolving Smalltalk for the Age of the Net

The Age of the NetBack to 1970s timesharing or 1990 X-terminals?

Page 53: Newspeak: Evolving Smalltalk for the Age of the Net

System software has to be local

UI issues

Depend on Reliable, Fast, Cheap Network

Make you “reboot” - it’s called: session expired

Web Apps have Downsides

Page 54: Newspeak: Evolving Smalltalk for the Age of the Net

Combine advantages of web services and traditional client applications

Always Available (even w/o network)

Always Up to date

Run locally, think globally

Restart-free

Network Serviced Applications

Page 55: Newspeak: Evolving Smalltalk for the Age of the Net

Maintains software and data on server

Provides backup, audit trail, software distribution & maintenance

Software distributed and updated when client syncs with server

Client can run offline using locally cached software and data

Sync does not imply application restart

Network Software Service

Page 56: Newspeak: Evolving Smalltalk for the Age of the Net

Hotswapping: Running applications can be updated on-the-fly over the network

Modules: well defined units of deployment and update

Security: Object capability model

Orthogonal Synchronization: Natural update of program and data*

Platform Support for Network Serviced Applications

Page 57: Newspeak: Evolving Smalltalk for the Age of the Net

Work in Progress

Expect some tweaks to syntax and semantics

Implementation still incomplete - especially libraries

Working toward public release

to be open sourced under Apache 2.0 license

Status

Page 58: Newspeak: Evolving Smalltalk for the Age of the Net

Libraries

System issues: Linux & Mac Native GUI, FFI refinements

Concurrency: value types, actors

Orthogonal synchronization

Object literals, Metadata, Access control, Pluggable Types

Future Work

Page 59: Newspeak: Evolving Smalltalk for the Age of the Net

Message-based programming

Component style modularity

Virtual classes, mixins, class hierarchy inheritance

Object capability model and security

Synergy

Page 60: Newspeak: Evolving Smalltalk for the Age of the Net

Mirror based reflection

Actor style concurrency

Pluggable types

Synergy

Page 61: Newspeak: Evolving Smalltalk for the Age of the Net

Credits

Peter Ahe

Vassili Bykov

Yaron Kashai

Eliot Miranda (emeritus)

Page 62: Newspeak: Evolving Smalltalk for the Age of the Net

This file is licensed under the Creative Commons Attribution ShareAlike 3.0 License. In short: you are free to share and make derivative works of the file under the conditions that you appropriately attribute it, and that you distribute it only under a license identical to this one. Official license.

The original Australopithecus skull image on slides 38/39 is the work of Albert Salguero and was licensed under a very similar license (version 2.5 of this license).

The Newspeak eye used in the bullets, slide background etc. was designed by Victoria Bracha and is used by permission.