Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It seems to me to be a pointless, hacky kludge. As with every other ORM, the abstraction will leak as soon as you do anything interesting. Even if it doesn't leak, there is mental stress involved with convincing yourself that it won't. And then you still have the performance problems. How does this make life easier?

What am I missing? Is this just for people who need to do "SELECT * FROM comments WHERE articleid=?" and don't want to learn even that much SQL?



Well if you put is this way, all is lost: you've already decided it WILL leak. Without checking.

What are you missing?

It's not that user wouldn't know SQL. It's that code like this is more readable because you don't do a mental switch in your brain. I'm all for it: see my story [1] for a take on readability.

Or just accept the fact that there are tools around for mature people who enjoy it. DHH didn't create his ORM for dumb people, he did it because it made his hackin' universe more pleasurable. Some dumb people used it later, but who cares.

[1] http://inthephase.org/back-to-ruby


As I see it, its easier to mix any subset of procedural, oop, or functional code than it is to mix either of those with relational queries. Operating on query results WITH Ruby is easy. Writing relational queries AS ruby is a big impedance mismatch. There isn't a simple mapping I can hold in my head. Here there be magic, in the form of implicit joins. Also, good luck trying to optimize.

It's not that I've decided it will leak, it's that I can never quite trust that it won't. I would have to continually prove to myself that my code is right. It's a weakness of mine that if I don't 100% understand the code I'm writing, I worry and that slows me down. That code becomes something I can't quite get out of the back of my mind.

Also, I don't buy your readability argument. I can read and think in SQL just fine. Yes, SQL can be complicated, but only when the problem requires it. It maps very directly and naturally on to the problem of querying. There isn't much in SQL that isn't necessary. There isn't much in SQL that is missing. It's already as simple as can be. To make it any simpler makes it worse. Mixing the asking of a question with the processing of the answer makes both parts harder to understand.

Perhaps it is easier to read for some people, but I think that's likely because they just aren't very good with SQL yet. So, this seems to me to make code less readable and more difficult to reason about. I don't see the advantage.


Don't use it and don't complain then.

Btw I actively use SQL since 1997 so I guess I have quite a proficiency. Still my point of readability wins, at least for me. So you see, your argument about readability doesn't hold for some people. Mine too, but I don't complain.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: