sábado, 19 de noviembre de 2011

Fastruby 0.0.16 released with ruby 1.9 support

Fastruby is a gem which allows to execute ruby code much faster than normal, currently in a state of transition between a spike and a usable gem, it is released when possible with incremental improvements.
The v0.0.16 release simply adds support for ruby 1.9, also fastruby was fixed for ruby 1.8 running with rvm (ruby1.8 patch 334), the big disclaimer here is that ruby1.9 specific code such fibers and new hash syntax won't work and fastruby is slower than ruby1.9 (both issues will be solved in next releases)
All code working with fastruby on ruby1.8 now will work with fastruby on ruby1.9.

Install

You can clone the repository at github:
git clone git://github.com/tario/fastruby.git
git checkout v0.0.16
Or install it using gem install:
gem install fastruby 
Platforms Supported
  • Ruby 1.8 patch 352
  • Ruby 1.8 patch 334 (tested using rvm)
  • Ruby 1.9 patch 180 (tested using rvm)


jueves, 10 de noviembre de 2011

Migrating everthing to ruby1.9

Since the warning I get from a excellent talk of @yhara at @RubyConfAr, ruby 1.9 is the present while ruby 1.8 is the past. The next step regarding my projects is to ensure that all works on ruby 1.9 (but keeping the compatibility with ruby1.8 at the same time)
This is the status of the more important projects.

ImageRuby

All tests on ImageRuby spec works with 1.9,2-p180 thanks to the contribution fix of amadanmath. Of course I will be listen to bug reports regarding ruby1.9 compatibility

Shikashi (and dependencies)

All tests on Shikashi spec works with 1.9,2-p180. Specific ruby 1.9 syntaxis are not convered by the spec. I have created a new issue for this (the issue corresponds to partialruby gem)

To make shikashi fully compatible with ruby1.9, I must find a replacement for RubyParser which is not compatible with some of ruby 1.9 specific syntax, for example, RubyParser is unable to recognize the new syntax for hashes of ruby 1.9

Fastruby

This is the most complex case, these are the remaining issues:
  • Main headers of fastruby won't compile since these sources use syntax not supported by ruby1.9
  • Use of C-Api specific to ruby1.8
  • Remove support for syntax specific to ruby1.8 (only when run under ruby1.8)
  • Add support for syntax specific to ruby1.9 (only when run under ruby1.9)
  • RubyInline does not work with ruby1.9
  • RubyParser does not work with ruby1.9

I will fork or find a fork of rubyinline to fix issues related with ruby1.9 compatibility, for the case of RubyParser (affecting shikashi too) I will replace parsing using Ripper which is the native out-of-the-box implementation of parsing on ruby1.9

martes, 1 de noviembre de 2011

Fastruby 0.0.15 released. Callcc and continuation objects!

Fastruby is a gem which allows to execute ruby code much faster than normal, currently in a state of transition between a spike and a usable gem, it is released when possible with incremental improvements.
The v0.0.15 release adds the support for continuation objects created using callcc function. To acchieve this, the implementation uses the non-lineal stack created on previous releases.
Also this release adds a few extra language support improvements such as method default arguments

Install

You can clone the repository at github:
git clone git://github.com/tario/fastruby.git
git checkout v0.0.15
Or install it using gem install:
gem install fastruby

New Features

Fixes

Examples of code being supported

Example of continuation calls, tail recursion


require "fastruby"

fastruby '
class X
def fact( n )
a = callcc { |k| [ n, 1, k ] }
n = a[0]
f = a[1]
k = a[2]
if ( n == 0 ) then return f
else
k.call n-1, n*f, k
end
end
end
'

p X.new.fact(6) # 720

Default Arguments
require "fastruby"

fastruby '
class X
def foo(a,b = a.reverse)
a + b
end
end
'

p X.new.foo("13") # 1331
p X.new.foo("xx", "yy") # xxyy

Passing proc objects as blocks
require "fastruby"

fastruby '
class X
def bar
yield(1)
yield(2)
yield(3)
end

def foo
pr = proc do |x|
p x
end

bar(&pr) # passing proc as a block
end
end
'

X.new.foo

Receiving blocks as proc objects
require "fastruby"

fastruby '
class X
def bar(&pr)
pr.call(1)
pr.call(2)
pr.call(3)
end

def foo
bar do |x|
p x
end
end
end
'

X.new.foo