views:

352

answers:

3

I am continuing to delve into Erlang. I am thinking of starting my next web project using Erlang, and at this stage the only thing I will really miss from Ruby on Rails is ActiveRecord.

Is there a good alternative technology for Erlang?

Update: The closest I have come to a solution is to ErlyDB, a component of ErlyWeb.

ErlyDB is a database abstraction layer generator for Erlang. ErlyDB combines database metadata and user-provided metadata to generate functions that let you perform common data access operations in an intuitive manner. It also provides a single API for working with different database engines (although currently, only MySQL is supported), letting you write portable data access code.

+4  A: 

I don't think there really is at the time of this writing. That may be because the kinds of systems being written in erlang and the type of people writing them don't really call for Relational Databases. I see much more code using mnesia, CouchDB, Tokyo Cabinet and other such alternative database technologies.

That's not to say someone might not want to create something like active record. It's just hasn't really been a need yet. Maybe you will be the first? :-)

Jeremy Wall
+3  A: 

Well, the major advantages of ActiveRecord (as I see it) are:

  1. You can persist your objects in a relational database nearly transparently.
  2. You can search the database by any attribute of your objects.
  3. You can validate objects when persisting them.
  4. You can have callbacks on deleting, updating, or inserting objects.

With Mnesia:

  1. You can persist any Erlang data absolutely transparently.
  2. Using pattern matching, you can search the database by any attribute of your data or their combination.
  3. QLC gives you a nice query interface for cases when pattern matching isn't enough.

No solutions for validating and callbacks, however...

So, what else do you have in ActiveRecord that is lacking in Mnesia?

Alexey Romanov
I guess part of the problem is that I am not quite ready to give up my RDBMS. I know the tools, I know how to optimise and scale. Perhaps this is just fear of the unknown.
Toby Hede
Then take the plunge. It'll be good for ya just to know all the issues when you do it differently. It's a lot easier to make a good call when you know multiple approaches. A bigger toolbox can come in handy sometimes.
Jeremy Wall
I am wondering if some of the issue is that Erlang is not really suited for web apps at the moment.
Toby Hede
+1  A: 

Some googling reveals libs / clients / wrappers for Couchdb described "ActiveRecord like libraries like CouchFoo", and advise to steer clear:

http://upstream-berlin.com/2009/03/31/the-case-of-activerecord-vs-couchdb/

http://debasishg.blogspot.com/2009/04/framework-inertia-couchdb-and-case-of.html#

as to your comment on "not suited for web apps yet", I think the pieces are there: mochiweb, couch, yaws, nitrogen, erlyweb. There's some powerful tools, very different paradigm, certainly, from rails, django and PHP.

Gene T
This is really interesting stuff, and reflects the thinking I have gone through recently. I want ActiveRecord because I am so tied to a particuar way of thinking and reasoning about software. I am looking much more seriously at CouchDB as an alternative to MySQL.
Toby Hede