For the book I’m writing on IronRuby I’m deciding which way to go to
demonstrate how IronRuby can leverage the .NET framework.
The beginning of the sample application should implement some database
layer. My first instinct is to go with Linq-to-SQL and consume those
from a ruby application.
I have a problem with ActiveRecord that comes with Rails, because often
doesn’t allow me to the things I want to do out of the box. And when I’m
App Dev mode I don’t really want to think about customizing the
I’m using so that it fits my needs. I should just have to configure it
start developing. For this reason I don’t consider ActiveRecord to be
sufficient for most enterprise database systems and definitely not
ones. I don’t think it would be a good idea to let .NET devs jump to an
that won’t handle the more complex enterprise scenario’s out of the box.
I’m thinking of writing a real ORM for Ruby ala NHibernate one that uses
DataMapper with an IdentityMap backed by a Unit Of Work, when I’m
with the book. It should also have Sql Generation that is highly
for each platform it supports (not just say because mssql is from ms we
won’t provide the best support for it we can) and maybe make it support
linq-to-sql syntax. Obviously I can’t build that in 2 days so I’ll have
drop that idea for a while
A second option I have in mind is rolling my own implementation of the
ActiveRecord pattern, using database reflection, an ADO.NET backend and
metaprogramming since it has a very limited scope for the book. I’m
much in favor for a unit of work implementation for my dataaccess.
At this moment I’m favoring the Linq-to-Sql (C#) approach because it has
- I demonstrate interop with one of my own project assemblies and how
can extend that using IronRuby.
- I don’t have to write my own ORM
- I won’t be stopped in my writing by features that haven’t been
The downside of that approach is that it will be hard to show an example
that makes real extensive use of metaprogramming.
A second concern I have for the Linq-to-SQL approach is that that will
work on a windows box, because I don’t think the mono-project has an
Then a last way of doing it would be to use ActiveRecord from the castle
project or SubSonic where the ActiveRecord implementation of the
CastleProject will be the one that handles most edge cases. The reason I
bring these 2 up is that I already got questions from people asking me
put examples up on my blog about using those things from IronRuby. At
point I haven’t put too much on my blog yet because I’m pretty busy
And I think every week I wait I’m more close to being able to use as
pure ruby as I can.
Any thoughts ?