MagLev is a Ruby implementation built by GemStone on their Smalltalk VM. GemStone/S, which is GemStone's Smalltalk product, been around for decades and is particularly known for it's mature distribution and persistence capabilities.
MagLev was announced in 2008, and the team has been busy working on it ever since. After a while in a private alpha, the cat is now out of the bag: a public version of MagLev is now available, which includes the MagLev source code which is hosted at GitHub.
To try MagLev, first get the source with a quick
git clone git://github.com/MagLev/maglev.git
followed by a
./install.sh
in the MagLev source directory and follow the instructions it provides.
To start MagLev use
rake maglev:start
which fires up the system. A quick way to run Ruby code is maglev-irb
, which will connect to the common MagLev backend; maglev-ruby
and maglev-gem
are also available.
A quick dig around the examples directory brings up the hat_trick example that Avi Bryant showed at the first MagLev demo. It showed off the persistence features, which allowed to ѕet up an object in one irb
instance and then access it in another.
To reproduce it, simply fire up MagLev and two maglev-irb
instances. To make an object execute this in one maglev-irb
instance:
Maglev.persistent do Maglev::PERSISTENT_ROOT[:stuff] = ["hello world"] end Maglev.commit_transaction
Switch over to the other maglev-irb
instance and execute:
Maglev::PERSISTENT_ROOT[:stuff]
which will return the string "hello world".
Obviously, this is a very simple demo of the persistence features; for more details of MagLev's persistence API see the docs.
A more slightly involved example is an implementation of Ruby's PStore using the persistence features. It shows how GemStone's persistence features make it easy to keep whole object graphs persistent without having to deal with an ORM.
While Rails is not yet supported on MagLev, working Rack and Sinatra examples are available.
A public Trac for MagLev is available to track the progress. For compatibility, this graph hows the number of passed RubySpecs, whereas links to detailed results are available too.
No details about licensing seem to be available on MagLev, but GemStone does offer free versions, eg of GemStone/S that bundles the web framework Seaside and is free up to 4 GB of data.
While there's a lot of buzz around the NoSQL databases these days, GemStone/S is a mature solution that's been around for decades. MagLev now tightly integrates these features with Ruby. What's your take - will you try MagLev?
Community comments
Re: MagLev Ruby VM Now Available, Brings GemStone's Persistence to Ruby
by Conrad Taylor,
Re: MagLev Ruby VM Now Available, Brings GemStone's Persistence to Ruby
by Werner Schuster,
Re: MagLev Ruby VM Now Available, Brings GemStone's Persistence to Ruby
by Conrad Taylor,
Your message is awaiting moderation. Thank you for participating in the discussion.
First, an easier way to implement the above example would be to do the following:
replace
with
BTW, Maglev::PERSISTENT_ROOT Hash is the persistent root for objects within Maglev.
Thus, in order to access a persistent object within the Maglev system, it needs to be reachable from
this persistent root. A cool example of Maglev would be to create a module that can be included in
our model(s) for enabling this persistent goodness. For example,
maglev_model.rb:
Now, let's create the Post model and this will be a snap because we have done most of the work by
creating a reusable module, MaglevModel, for enabling persistence within the Post class:
post.rb:
Now, if we were to run the above code, one should see the following:
Now, you should have noticed in the above that there was no database schema, SQL, or other
things that one would normally see in regards to setting up a relational database. Thus, the only
thing that I needed to do was include the MaglevModel, and define an initialize and to_s instance
methods on my Post class. That's all to it. BTW, MaglevModel module is a user created module and
one can customize and name as necessary for your project. Lastly, if you're a Rubyist, then I would
recommend taking a look Maglev.
Happy coding,
-Conrad
Re: MagLev Ruby VM Now Available, Brings GemStone's Persistence to Ruby
by Werner Schuster,
Your message is awaiting moderation. Thank you for participating in the discussion.
@Conrad: Great - thanks for the comment & sample.
And I agree - it's great to see MagLev available to everyone;