AmberVM 0.0.19

Good news everyone!

Murphy from murfy.de and me set together to work on the next release of AmberVM. It was quite an endeavor, he has worked parallel on a different approach on the ECMA interpreter and and we took the time to merge his work into AmberVM itself so combine the best of the two worlds. We worked through a whole night to get everything done but finally every spec is working perfectly again.

The result are a few cool new features in the ECMA interpreter and Amber itself. The main changes are that the whole parser is rewritten from scratch, or rather we decided to merge in Murphy’s parser for the AmberVM ECMA implementation, then another big move is that the namespace for functions and variables are now combined in AmberVM, this allows it to handle functions as variables or even parameters.

A more complete list of new features of AmberVM in version 0.0.19:

  • ambervm now supports -s switch to show the source code it executes.
  • ambervm now supports -p switch to show a pseudo code that describes the internal representation of the code it executes.
  • The Namespace for Functions and Variables is now merged.
  • The this keyword is working corectly!
  • Objects scope correctly
  • Now a big thing, Closures are working, even mostly correct. Only some odd cases brake the systems as using global variables in Closures. But that’s bad style in my eyes so just don’t do it ;).
  • Some optimization.

So let’s see how this works. Have fun with it and if you happen to decide to use it, drop me a line ;)

Posted by Heinz N. 'Licenser' Gies Wed, 12 Aug 2009 12:23:00 GMT


Ruby on Rails on Solaris x86

The last few days I have fought with getting ruby and rails to run on a Solaris host, and let me tell you it isn’t easy!

The worst problems to tackle were:

  1. readline is not working properly
  2. libiconv is not working properly
  3. nothing is in the effing PATH

readline

Okay it is really nessessarry but to be frank irb without readline support sucks. So first of all the task is to get a up to date readline library, good news are Solaris is a Unix related OS so it is not much of a problem.

wget ftp://ftp.cwru.edu/pub/bash/readline-6.0.tar.gz
gzcat readline-6.0 | tar xf -
cd readline-6.0
configure: ./configure --prefix=/opt/readline
make
sudo make install

There we go you now have the latest readline library!

libiconv

This one is more tricky, at least to figure out it is actually messed up. The symptoms were that my rails told me:

method 'camelize' for 'app':String not found

Hey of cause that means the libiconv is missing … narf … to be honest I’d hat hoped that the rails libs, that are not loaded because libiconv isn’t there complain instead of silently dieying but well – I figured it out… So same procedure as libreadline:

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.1.tar.gz
gzcat libiconv-1.9.1.tar.gz | tar xf -
cd libiconv-1.9.1
configure: ./configure --prefix=/opt/readline
make
sudo make install

bringing it together

Now we have all the libs, next task is to compile ruby. But beware it is important to tell ruby where to find the libraries as it won’t go looking for them on it’s own.

export CFLAGS="-I/opt/iconv/include/ -L/opt/iconv/lib -L/opt/readline/lib -I/opt/readline/include/readline" 
export CPPFLAGS="-I/opt/iconv/include/ -L/opt/iconv/lib -L/opt/readline/lib -I/opt/readline/include/readline" 
export LDFLAGS="-L/opt/iconv/lib -R/opt/iconv/lib -L/opt/readline/lib -R/opt/readline/lib"

This takes care of the library locations next to compile ruby itself, which is quite easy:

./configure --prefix=/opt/ruby --enable-pthread
make
make install
Done, the --enable-pthread option is only needed for ruby 1.8.* ruby 1.9.1 seems to detect that on it's own. Now you can go and install rails via gems and it works like a charm :)

Posted by Heinz N. 'Licenser' Gies Wed, 29 Apr 2009 07:23:00 GMT


rVM 0.0.17

As promised the new release has a few exciting features!

The ECMA Script (also widely known as Java Script) compiler kind of got the flaggship of rVM for the moment so this (and likely the next few releases as well) will focus on this language. The reason for it is not that we want rVM to become a ECMA Script interpreter but that maintaining more than one language is too much work at this stage – since not even ECMA is fully supported yet.

We redesigned the way rVM programs access rVM Library functions (the stuff written in ruby). While before the functions were accessing for every code executed in the rVM access to them is now limited to core libraries (or everything the compiler declares as such). The advantage of this is to provide a language native interface to those functions. As an example, rVM knows the sin() function, ECMA script does call it Math.sin(), the Math compiler calls them just ‘sin()’ and yet another language might call it ‘sinus()’, now since those functions would be ‘aliased’ in core libraries every lanuage can call them as they want to give a native feeling while writing in it.

That brings a light change in the layout of the language classes along, Language#env will now provide a environment with the core libraries loaded, as long as they exist.

ECMA script got a good bit of the Math library shipped along with this release, meaning that the benchmarks that are used now run the same in rVM and rhino. I would guess that most code that runs in rVM will run out of the box in rhino or other ECMA interpreters since rVM is more strict then most others. The other way round it sadly isn’t guaranteed since the ECMA compiler still misses some features.

To the topic of speed, since we can distinguish now between rVM functions and self implemented functions this gave us a little boost in speed, also some tweaks in the environment handling add a bit speed. Still we can claim to be, as murphy put it so nicely, ‘the slowest ECMA VM around’! Hah! Beat that Google and Mozilla! Even so rVM greatly wins speed with ruby 1.9.1, the benchmarks are nearly twice as fast with the new ruby version!

You can get the new version either via gem (once it is updated at rubyforge), from rubyforge (http://rubyforge.org/frs/?group_id=6626) or directly from here (http://code.licenser.net/projects/list_files/rvm).

Have fun!

Posted by Heinz N. 'Licenser' Gies Fri, 02 Jan 2009 07:13:00 GMT


rVM's feature

Good news everybody!

rVM started to be a quite actively developped again. A friend of mine murphy from http://murfy.de/ has joined the development team, so we’re two now. I greatly respect him and he is quite knowledgeable when it comes to ruby, but most importantly enough he’s crazy enough to jump in a projekt as this. So he will be a great gain for rVM.

Actually he already was very helpful. We have set down the last to days and worked on it. A few good results have come up, including that we finally got a (somewhat) usable benchmark. rVM is only about 20 times slower then the rhino VM when interpreting ECMA script. That does should slow but hell it is fast enough for the moment (murphy stopped me to optimize and focus on making it work more conform first – which is one of the good things that already came from this cooperation :P).

So the ECMA interpreter is working better and better, meaning that after a few more fixes and additions I’ll release version 0.0.17 soon (in the next days I hope). That release will feature a nice new feature for ECMA, a core library that starts to provide a ECMA-like access to function objects like Math.

Posted by Heinz N. 'Licenser' Gies Tue, 30 Dec 2008 17:17:00 GMT


rVM envolves

Lately I got some chance to work more on rVM, and there is some good progress.

Just the day before version 0.0.12 was released and it steadily progresses towards the 0.1.0. 0.0.12 ships with some nifty new features which mostly results for the fact that I already got the chance to use rVM in two projects, and I’ve to admint I’d not thought it would really work out that well.

A few words to what is new, 0.0.12 now pretty completely covers ECMA script, of cause there are still some things that do not work like the option to create own objects is still missing and the support for leaving away ’;’s in some places is missing. On the other hand it runs quite stable now and even passes most JSON test from http://json.org. Only some negative tests are not passes as the rVM compiler is too forgiving or implements non required features as allowing expressions within a associative array.

For the goal of making rVM easily usable, which is in my eyes one of the most important tasks, acts_as_rvm_type was added which allows to declare own objects as types for rVM in just a few lines.

Here a short example for that:

class Dog
  attr_accessor :race, :name
  include RVM::ActsAsRVMType
  acts_as_rvm_type
  register_variable :race, false # Declares race as a readonly variable in rVM
  register_variable :name # Declares name as a writable variable for rVM
  register_function :bark # Declares bark as a function of the dog object
  def initalize race, name
    @race = race
    @name = name
  end
  def bark
    puts "#{@name} barks!"
  end
end

This is in my opinion a big step forward, and it works pretty smoothly with Rails which is nice, some time in the future I’ll add a rails plug in to make this even easier.

At another note due to adding a good few (still not enough I fear) specs to then rVM implementation lots of bugs were tossed away in the last few releases.

Visions

There are a few things I very much would love to see for rVM, one and perhaps the most ambitious is that with rVM it would be possible to run Tests or Specs over JavaScript code without the need of a browser – given it would take a good bit of effort and certainly some work to make the ECMA implementation more conform but I believe that it /is/ possible. Even now I think that for basic and well written JS code rVM might do the job in parsing and interpreting it correctly. But this is just a crazy idea for me ;) while it would be pretty darn cool to be able to do all tests of a rails app within ruby and no need for any foreign frameworks.

Posted by Heinz N. 'Licenser' Gies Mon, 29 Dec 2008 01:27:00 GMT


rVM on Rails

Since version 0.0.13 rVM includes rvm/rails which is a easy bridge between rails and rVM that allows to quickly add scripting capabilities to rails applications.

The basics are pretty simple rvm/rails comes in 2 parts: First a plugin for ActiveRecord::Base that makes it easy to use act_as_rvm_type with it and second functions specialized for Rails. Currently this is only print() which is used to generate output.

If you are interested have a look at the Screencast or the API documentation .

Posted by Heinz N. 'Licenser' Gies Fri, 01 Aug 2008 02:47:00 GMT


rvm on speed?

After finding this link I got the crazy idea to write the core of the VM in C. I am quite certain it would give a good bit of speed boost especially concidering that at this point speed might matter.

What is the downside? Well I can think of two – it is way more likely that I mess up something in C and thus create a bug that allows harm the system the VM runs, the second is … our best friend Microsoft Windows. Also I’ll have to look into how JRuby handles things like ruby extensions.

So I was thinking to package the whole thing with two versions of the VM core, one written in C if you are either trustfully or sure enough bugs won’t harm too much or speed does matter a lot for you. Then a second version written in pure ruby which would likely be a good bit slower but only bugs in the ruby interpreter would be a concern.

Any thoughts?

Posted by Heinz N. 'Licenser' Gies Tue, 01 Apr 2008 05:50:00 GMT


rVM 0.1.0

Well rVM 0.1.0 is on the way with lots of new features (yea I know 0.0.6 - 0.0.9 were never even released yet) but they might on the way, whenever a part of the functionality is done.

So as part of rVM 0.1.0 I will make a few screen casts about how to use rVM, and what makes it nice - my thoughts and plans on it and all that. Bare with me I am new to this medium and certenly have some way to go before I bring screen casts to a perfection where other are ;) but well we all have to start at one point.

This one is showing the very basic steps about how to include rVM into a project, a few easy steps to get this done.

Second part is the RVM::Library class to load function libraries using RVM into a ruby project.

If you are interested: watch it

Posted by Heinz N. 'Licenser' Gies Sat, 15 Mar 2008 00:23:00 GMT


next release rVM is coming!

I won’t write too much here, considering I already wrote a news post on the redmine side for it. Non the less if anyone at all reads this blog it’s just fair to keep you up to date right?

As a quick overview what will come:

  • ECMA Script / JS - including a lot of functionality but not all features (hence ECMA Scirpt is quite extensive)
  • Objects - a object model will join rVM and have it’s debut in the ECMA implementation
  • Examples how to use rVM compiled code as libraries

That are only some short notes for a more extensive discussion please have a look at the News Post as I am not going to cheat and post the entire thing again ;).

– Lice

Posted by Heinz N. 'Licenser' Gies Tue, 11 Mar 2008 21:37:00 GMT


rVM

rVM going public

Okay, here we go, I published some ruby gems with rVM, it is way not done and leaks some important features but it is working already. The latest version, SVN trunk, currently supports a quite nice and complete math interpreter. Sure it does not do as much as some full blown implementations yet it can do quite a lot.

It supports now:

  • All usuall opperations, +, , -, /, ^ with right priorities.
  • Functions sin(123), and custom functions if you wish.
  • Parentheses to group operations and overwrite operator priorities.
  • Variables, as in x + 3. Those can be set outside of the code by manipulating the passed environment.
  • Assignments, as in x=23+19. Which can be read outside the code by reading from the passed environment.
  • Sequences of expressions separated by the ; operator.

With the latest two items here new to the implementation and perhaps most important. And most interesting. One feature added today is allowing to generate sequences by using ; as a separator, thus making it possible to chain up operations over multiple lines.

If you feel like checking it out:

svn co http://code.licenser.net/rvm/trunk rvm
cd rvm
rake gem
gem install pkg/

also

rdoc README lib/

gives you a nice overview about some things as well as the short howto and example at

http://code.licenser.net/documents/show/5

That will install you the latest gem from the trunk – Have fun and I’m always happy about feedback ^^ and or tickets at:

http://code.licenser.net/projects/show/rvm

Posted by Heinz N. 'Licenser' Gies Wed, 05 Mar 2008 05:18:00 GMT