Slide 1

Slide 1 text

Smalltalk On Rubinius Konstantin Haase

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Why implement Smalltalk on Rubinius?

Slide 11

Slide 11 text

Why create a programming language?

Slide 12

Slide 12 text

Why create?

Slide 13

Slide 13 text

"When you don't create things, you become defined by your tastes rather than ability. Your tastes only narrow and exclude people. So create." why the lucky stiff

Slide 14

Slide 14 text

Why a programming language?

Slide 15

Slide 15 text

About programming languages: "I don’t like any of them, and I don’t think any of them are suitable for the real programming problems of today, whether for systems or for end-users" Alan Kay

Slide 16

Slide 16 text

Problem Oriented Programming Languages Cairo (~120k SLOC in C) rewritten in less than 400 lines

Slide 17

Slide 17 text

Why Smalltalk?

Slide 18

Slide 18 text

Why Rubinius?

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

1 + 1 1 + 1

Slide 21

Slide 21 text

this is it this.is.it

Slide 22

Slide 22 text

GoGaRuCo rock: #hard GoGaRuCo.rock :hard

Slide 23

Slide 23 text

doc convertFrom: #xml to: #yaml doc.convert(:xml, :ruby)

Slide 24

Slide 24 text

doc convertFrom: #xml to: #yaml doc.convert from: :xml, to: :ruby

Slide 25

Slide 25 text

[ 42 ] proc { 42 }

Slide 26

Slide 26 text

anArray do: [ :each | each doSomething ] an_array.each do |element| element.do_something end

Slide 27

Slide 27 text

Textmate version = 2 ifTrue: [ 'no way' ] ifFalse: [ 'thought so' ] if Textmate.version == 2 "no way" else "thought so" end

Slide 28

Slide 28 text

Storage current store: #foo; store: #bar storage = Storage.current storage.store :foo storage.store :bar

Slide 29

Slide 29 text

Smalltalk claims to look like: 'English'. Judge yourself. Does it. Ruby.claims.to.look. like "English" Judge.yourself; Does.it?

Slide 30

Slide 30 text

Reak github.com/rkh/Reak Like Squeak but with R File based (as opposed to image based)

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

The Rubinius Compiler Pure Ruby Modular and Flexible lib/compiler

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Parsing with KPeg github.com/evanphx/kpeg

Slide 35

Slide 35 text

" from Reak.AST.Self " grammar: g [ ^ g str: 'self' ] # from Reak::AST::Return def bootstrap_grammar(g) g.seq "^", :sp, g.t(:expression) end

Slide 36

Slide 36 text

Rubinius Bytecode

Slide 37

Slide 37 text

$ rbx compile -B -e 'puts "Hello World"' 0000: push_self 0001: push_literal "Hello World" 0003: allow_private 0004: send_stack :puts, 1

Slide 38

Slide 38 text

$ rbx compile -B -e 'puts "Hello World"' 0000: push_self 0001: push_literal "Hello World" 0003: allow_private 0004: send_stack :puts, 1

Slide 39

Slide 39 text

$ rbx compile -B -e 'puts "Hello World"' 0000: push_self 0001: push_literal "Hello World" 0003: allow_private 0004: send_stack :puts, 1

Slide 40

Slide 40 text

$ rbx compile -B -e 'puts "Hello World"' 0000: push_self 0001: push_literal "Hello World" 0003: allow_private 0004: send_stack :puts, 1

Slide 41

Slide 41 text

$ rbx compile -B -e 'puts "Hello World"' 0000: push_self 0001: push_literal "Hello World" 0003: allow_private 0004: send_stack :puts, 1

Slide 42

Slide 42 text

class Object dynamic_method(:display) do |g| g.push_self g.push_local(0) # first argument g.send(:puts, 1, true) g.ret end end display "Hello World"

Slide 43

Slide 43 text

Reusing the Rubinius tool chain

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

class Reak::Compiler < Rubinius::Compiler class Parser < Stage stage :parser next_stage Generator end end

Slide 46

Slide 46 text

class CustomNode < Reak::AST::Base def self.bootstrap_grammar(g) # grammar definition end def bytecode(g) # bytecode definition end end

Slide 47

Slide 47 text

class ConstantAccess < Rubinius::AST::ConstantAccess include Reak::AST::Node Reak::AST::Primary.push self def self.bootstrap_grammar(g) g.t /[A-Z][a-zA-Z0-9_]*/ end # no bytecode definition necessary end

Slide 48

Slide 48 text

Rubinius.AST.TrueLiteral subclass: #TrueLiteral [ Reak.AST.Primary push: self. self include: Reak.AST.Node. self class >> grammar: g [ ^ g str: 'true' ]. ]

Slide 49

Slide 49 text

" Remember cascades? " g pushSelf; pushLocal: 0; send: #puts args: 1 private: true; ret.

Slide 50

Slide 50 text

Reak.AST.Base subclass: #Cascade [ Reak.AST.Expression push: self. bytecode: g [ g pushSelf. cascadedSends do: [:send | g dup. send bytecode: g. g pop ]. lastSend bytecode: g. ] ]

Slide 51

Slide 51 text

Thanks! github.com / rkh / presentations