redline smalltalk: a future on the java virtual machine by … · 2017-02-20 · why smalltalk on...

42
Redline Smalltalk: A Future On The Java Virtual Machine by James Ladd

Upload: others

Post on 31-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Redline Smalltalk:

A Future On TheJava Virtual Machine

by James Ladd

Page 2: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Redline Smalltalk:

A Future On TheJava Virtual Machine

by James Ladd

Page 3: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

HARD !

Page 4: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Demystifying compilers forthe JVM...

...with a trip through Redline's implementation

JVM = Java Virtual Machine

Page 5: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Why Java Virtual Machine?

Page 6: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Why The Java Virtual Machine?

Everywhere

On Everything

Great Performance

Always Improving

Page 7: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Why The Java Virtual Machine?

Some Companies

Only Support

The JVM!

Page 8: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Why The Java Virtual Machine?

Some Companies

Only Support

The JVM!

Page 9: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Why Smalltalk?

Page 10: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Why Smalltalk?

Productive

Flexible

Simple and Pure

Easy to Learn

Page 11: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Why Smalltalk On The Java Virtual Machine?

“… because nothing is as

productive as Smalltalk, and the

App has to run on the Java Virtual

Machine.” – Redline Smalltalk.

Page 12: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Compilers are hard!

Grammar

Lexer

Parser

AnalyserRuntime

Bytecodes

Page 13: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

The Pipe Line

From Source to Executable

Page 14: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Grammar: Defines Syntax -

From Small Things Big ThingsGrow

Page 15: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Parser:

Turns a Stream of Characters intoa Tree of Nodes

Page 16: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Analyser:

Walks Tree of Nodes

to

Determine What

to Generate

Page 17: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Generator:

Writes Executable Code

Page 18: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Runtime:

A Language Support Library

Page 19: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Class Library:

A Developer Support Library

Page 20: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Integration: Choice #1

Foreign Or Native?

Page 21: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Integration: Choice #2

Integrate With Other Classes?

Page 22: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

You CAN make a language forthe JVM...

Not as hard as you might think.

Page 23: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

The Execution Pipeline

Bringing It All Together

Page 24: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Smalltalk-80

A Simple language:

5 Keywords Vs Java's 53self, super,

true, false,

nil

Page 25: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Smalltalk-80

Simple expression syntax:

receiver message[: argument].

Page 26: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Smalltalk-80

Simple expression syntax:

receiver message[: argument].

1 + 1.

calendar at: date put: event.

vote increment.

Page 27: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Smalltalk-80

Simple expression syntax:

beer isGood: [beer drink]

Page 28: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Smalltalk-80 & Java

map at: key put: value.

map.atPut(key, value);

Page 29: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Transcript show: 'Hello javaOne'

Compiling An Example

Page 30: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Compiling An Example -Grammar: Defines Syntax

Thank you - Jim Idle - Temporal Wave LLC ([email protected])

keyword_expression returns [KeywordExpression keywordExpression] @init { kexpr = new KeywordExpression(); } : ( WHITESPACE KEYWORD bod { $kexpr.add($KEYWORD.text, $KEYWORD.line, $bod.binObjDescription); } )+ ;

← ANTLRWorks for Eclipse and IntelliJ. I used both.

Page 31: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Compiling An Example -Parser: Characters to Nodes

Program

Expression

StringKeywordClass

Transcript show: 'Hello javaOne'

Receiver Message Arguments

Transcript show: 'Hello..'

Page 32: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Compiling An Example -Analyser: What To Generate

Program

Expression

Class

Receiver

Transcript

Visit Program

Visit Expression

Visit Class

Generate a getClass('Transcript')

Page 33: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Compiling An Example -Generator: Writes Bytecode

Generate a getClass('Transcript')

Object Web - ASM Java bytecode manipulation and analysis framework

Page 34: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Compiling An Example -Runtime: Supports Language

Message Passing – Custom Method Lookup And Dispatch.– Charles Nutter added InvokeDynamic.

Smalltalk Object / Metaclass Hierarchy – Not Java Hierarchy

Block Support – Lambdas in Smalltalk.

Page 35: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Compiling An Example -Class Library: Supports You

Can use any Java Library with dynamic adaptors.

Page 36: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Compiling An Example -Integration

+ stdout: string

   JVM getStatic: 'java/lang/System' named: 'out'         as: 'Ljava/io/PrintStream;'.

     JVM arg: 0.

     JVM invokeVirtual: 'java/io/PrintStream'          method: 'print'          matching: '(Ljava/lang/Object;)V'.

Page 37: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Compilers Are Not That Hard

Page 38: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Your Own Language?

Page 39: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

The Java Virtual Machine(JVM) is a great platform.

Page 40: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Redline is Smalltalkfor you...

...supporting theway you work today.

Konstantin BulenkovKen Gilmer

Page 41: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

You can make a languagefor the JVM...

Not as hard as youmight think.

Page 42: Redline Smalltalk: A Future On The Java Virtual Machine by … · 2017-02-20 · Why Smalltalk On The Java Virtual Machine? “… because nothing is as productive as Smalltalk, and

Questions?

James Ladd @[email protected] http://redline.stwww.jamesladdcode.com