acts_as_conference 2008 ~ Rubinius ~ Evan Phoenix
RUBINIUS ~ Evan Phoenix
“Can we write the Ruby API in Ruby?”
Wants to make Ruby accessible to Ruby programmers. For example, Yehuda altered how printf works because it was buggy. Don’t need to know C.
Wants to improve the performance of Ruby. So far, micro-performance gains. Meaning, how fast does a method run? Adding primitive methods together. Now, they’re working on the macro-performance level.
Wants garbage collection to perform better. Rubinius has a generational garbage collector, the modern technique.
First-class features.
Foreign-function interface (FFI) layer binds to C functions, mainly structs.
Evan is demo’ing Rubinius in irb (“3 + 4 in irb was two years in the making”)
BlockContext
MethodContext
Really nice backtraces.
How to be a better programmer:
- you’re not the best programmer you know
- Evan reads about 50% of the commits
- find techniques that others use that you haven’t
Rubinius committer policy:
- direct commit access is granted after first patch is accepted
- one-commit threshold has tapped a talent pool
describe “Shotgun” do
it “converts a local var to an sexp” do
“a = 1; a”.to_sexp.should == [:block, [:lasgn, :a, 0, [:lit, 1]], [:lvar, :a, 0]]
end
end
class Actor
def self.after_loaded
Actor.metaclass.alias_method :private_new, :new
Actor.metaclass.alias_method :new, :spawn
Actor.metaclass.private :private_new
end
class def spawn(&prc)
channel = Channel.new
Thread.new do
channel prc.call
end
channel.receive
end
def current
Thread.current[:__current_actor__] ||= private_new(current_mailbox)
end
def current_mailbox
Thread.current[:__current_mailbox__] ||= Mailbox.new
end
private :current_mailbox
def receive(&prc)
current_mailbox.receive(&prc)
end
end
def initialize(mailbox)
@mailbox = mailbox
end
def send(value)
@mailbox.send value
self
end
alias_method :end
Because a lot of 1.9 is kernel changes, there will be a 1.8 kernel and a 1.9 kernel and you tell your Ruby program to use one or the other. Both can run on the same VM because of the architecture.