M4DBI - Models (and more) for DBI

March 31, 2008 at 23:47

Filed under: Computing — Pistos @ 23:47

http://purepistos.net/m4dbi

M4DBI is a new project I’ve been working on for the past couple months. Visit the M4DBI home page for technical details and project info. Here, I will just excerpt the Rationale statement.


I’ve worked in the past with DBI, ActiveRecord, Og, Kansas and Sequel. I also have some experience with ODBC and JDBC.

ActiveRecord is good, but it took up way too much RAM on a server where memory was not an abundant resource. I also ran into various annoying and frustrating problems. ActiveRecord didn’t always play nicely outside the realm of Rails, and I was never sure how stable my application would be after upgrading ActiveRecord.

One thing that bothered me about these ORMs was the fact that they encouraged what I thought was overusage of Ruby or Ruby-ized syntax for things that could be just as (or maybe even more?) easily and cleanly done in SQL, namely: schema definition and basic queries. I am reasonably proficient in SQL, so I considered this Rubification somewhat unnecessary, and also thought that sometimes it only obscured things because one would sometimes wonder what the underlying raw SQL was for the DDL statements or queries. Why not state it explicitly?

I also had POLS violated. Now and then I wouldn’t have a record set in memory when I thought I did (due to the maximally-delayed fetching design of Sequel); or a record which I operated on in Ruby didn’t have its changes synced to the database because I forgot to #save() it.

A general impression I got from these ORMs was that the ORM was being used to mould, contort and manipulate the database. I always thought that this was backwards; rather, the DB is the reality, and the ORM should conform to it, and convey the truth about it. Otherwise, it would be like having a camera which would alter the physical things that it was taking a picture of, instead of the camera merely being a viewport on the reality.

I realized that all I really liked about ORMs are models and the relationships between them. Otherwise, I really just wanted the low-level power and intimacy of SQL, married to the beauty of my favourite language, Ruby, topped off with these pleasant extras, models and relationships. And so M4DBI was born, as an attempt to address all the above issues.

Share This

window.location is not a function

March 24, 2008 at 13:12

Filed under: Computing — Pistos @ 13:12

“window.location is not a function” Well of course it isn’t.

Wrong

window.location( "http://blog.purepistos.net" );

Right

window.location = "http://blog.purepistos.net";

A silly mistake I made recently, one which left me head scratching for a while.

Share This

Faster applications by using SQL over ORM

February 14, 2008 at 23:00

Filed under: Computing — Pistos @ 23:00

If you only ever interact with your database through your ORM’s interface and syntax, you may be slowing your application down.

Now and then, I see developers do validations, constraints and hooks using their ORM, and think to myself: “Why don’t these people use their database to do that?”

(more…)

Share This

CRE available on free Wordpress hosting site

February 2, 2008 at 15:24

Filed under: Computing, Religion — Pistos @ 15:24

CatholicDestination.com is a Catholic website whose vision “is to become the premier supplier for Catholic Goods, Gifts, Sacramental items, Services and Information”. Further to this, they offer free blog hosting.

CD has recently installed the CRE, so all CD bloggers will have the ability to have scripture and catechism references activated with little intervention or maintenance on their part.

Thank you for installing the CRE, CatholicDestination.com!

Share This

Ruby: “string not matched”

January 3, 2008 at 9:35

Filed under: Computing — Pistos @ 09:35

I was debugging a Reby script and came across a most unusual error:

Reby error: string not matched
chanstats.rb:43:in `[]=’

Line 43 was:

@stats[ channel ][ :size_record ] ||= 0

which looks rather innocuous. I have a couple Hashes, one nested in the other. Or so I thought… Apparently, I had mistakenly initialized @stats with a string instead of a Hash. Testing in irb, everything becomes clear:

irb(main):001:0> s = "string"
=> "string"
irb(main):006:0> s[ 'hi' ] = 'foo'
IndexError: string not matched
        from (irb):6:in `[]='

I hope this helps people who can’t figure out why they’re getting “string not matched”.

Share This
Next Page »
Powered by WordPress.
Close
E-mail It
Socialized through Gregarious 42