5 Reasons DataMapper Will Deprecate ActiveRecord 5
Merb brought much attention to the ActiveRecord alternative ORM DataMapper and I feel like it’s going to put a serious hurting on ActiveRecord. My reasoning is based on the fact that alternate data storage technologies are gaining serious traction. The latest and greatest (couchdb, dynomite, cassandra, thrudb) are offering distributed document / object databases that will make creating highly scalable websites even easier and faster, oh yeah and they’re all free. With that in mind, I’m expecting a paradigm shift in data stores (big variable huh?). At the very least I expect Maglev to come true and the free/open source clones to follow. The model storage shift then becomes, how to you write the validations, callbacks, plugins and relationships for first class Ruby objects… DataMapper basically has all the pieces there already. With that in mind here are 5 reasons DataMapper will rule Ruby object data storage.
#1 Rails 3
(this is the big one) Rails 3 (Merb) will open Rails up to ORM alternatives like DataMapper. This will fuel uptake of DataMapper and others.
#2 property
This is a core difference in how DataMapper and ActiveRecord work. DataMapper allows the developer to define the property (attribute/column) in the class. Defining your attributes is better than letting the data store define it. This will become more apparent with the adoption of document/object databases that don’t define a hard schema.
#3 It’s Ruby
Defining properties in terms of real Ruby classes is the hotness. Take any ruby class then, include DataMapper::Resource… done.
#4 Laziness + Strategic Eager Loading
Yeah, one of DataMapper’s core features is it’s ability to iterate over associations without causing the n + 1 query problem. Whether dealing with SQL or Memcache or something new this will always be an issue. It’s 1 vs. many selects, io, or network hits it will never not be an issue. DataMapper handles this gracefully.
#5 Mapping Data vs. Record Handling
ActiveRecord is based on the assumption your storage is a database record. The entire library is written with that in mind. DataMapper is extensible and modular. Don’t need SQL? OK great, but you still need validations, properties, callbacks, and relationships. DataMapper has this covered whether it’s SQL, REST, CouchDB, or anything else. It’s easy to create something new.
