Live data from Hacker News

OrmHate

martinfowler.com

11–20 of 136 posts

Re: OrmHate

#11
post #3

"You have a relational mapping problem. 'I know', you say. 'I'll use an ORM.' You now have two problems." That just about sums up my experience with ORMs. Of course, like all things in the real world, experiences vary. However, I do think that generally, ORMs solve none of the difficult relational mapping problems and adds another layer of abstraction that complicates things like performance tuning to the point of ne…

Have you actually read TFA? Fowler's point is that yes, ORMs don't solve all of the really hard mapping problems, but save you a lot of boilerplate on the other 80-90%, and the hallmark of a good ORM is that it allows itself to be bypassed with relatively little hassle for those hard problems (like performance tuning).

Also from TFA: what do you suggest using instead?

Re: OrmHate

#12

    def user = User.findById(25)
    return user.getLocation().getAddress().getState() 
  
What happened during that execution? Was that 1 query or 50? Would it have been better to write a specific sql statement?

To me, this describes the biggest challenges with using or not using ORMs. I don't think there is an easy answer.

Re: OrmHate

#13

> There is a lot of truth to these charges, but such charges miss a vital piece of context. The object/relational mapping problem is hard. I suspect that context is precisely what underlies the common critiques of ORMs. Those people who best understand the inherent object-relational impedance mismatch tend to be the very people who conclude that the effort isn't worth it. In my admittedly anecdotal experience, I have…

And yet many ORMs such as ActiveRecord let you do this trivially, maintaining as much of it's functionality as you want, such as mapping column types to appropriate pl types. In my experience, even if you had a policy of all queries being written explicitly in SQL by all developers and encapsulating these into your own data access layer, you would still have quite a bit to gain from the well-tested community boilerplate in one of the available ORM packages.

Re: OrmHate

#14

I personally haven't heard/seen anyone griping about ORMs for a couple of years now. I thought the debate was over. Much like you rarely see anyone talk about stored procedures these days.

Please do come and have a talk with my (pointy-haired style) boss :) .

I take it you think stored procedures are generally good (at least that's what I think). But some people still believe that they'll migrate database architecture or some such. Also, some ORM's aren't fit for the task and give a bad name (Microsoft's Entity Framework v1 was especially horrible)

I'm definitely out of touch and I spend way too much time working with Microsoft SQL, but do people treat relational databases as "a crazy aunt" as Fowler says? (I still haven't tried NoSQL)

Re: OrmHate

#15

> There is a lot of truth to these charges, but such charges miss a vital piece of context. The object/relational mapping problem is hard. I suspect that context is precisely what underlies the common critiques of ORMs. Those people who best understand the inherent object-relational impedance mismatch tend to be the very people who conclude that the effort isn't worth it. In my admittedly anecdotal experience, I have…

> Those people who best understand the inherent object-relational impedance mismatch tend to be the very people who conclude that the effort isn't worth it.

You're showing a severe bias.

> I have found that ORMs are the most useful for the most trivial queries.

That's really what ORMs are for. Three joins, max. Any more than that and you really can't trust the ORM. It's a computer, after all, not a DBA.

Re: OrmHate

#16

> There is a lot of truth to these charges, but such charges miss a vital piece of context. The object/relational mapping problem is hard. I suspect that context is precisely what underlies the common critiques of ORMs. Those people who best understand the inherent object-relational impedance mismatch tend to be the very people who conclude that the effort isn't worth it. In my admittedly anecdotal experience, I have…

Any good ORM will let you write your query directly, and still save your the work of mapping the resultset to a collection of objects.

Re: OrmHate

#17
post #6
post #4

Earlier quoted context omitted.

The core of fowler's article is, "what is the alternative to ORMs?" - and the answer is there isn't much other than rolling your own. This is not at all analogous to PHP where there is an abundance of alternatives to it's mediocre design. PHP isn't hated because of its concept - a "web-based scripting language". It's hated because it's done very poorly. Just like a lot of bad ORMs Fowler refers to.

There is nothing wrong with PHP - it runs multi-billion dollar companies and it is the most ubiquitous language on the web for a reason.

Because it has near-zero barrier to entry. That doesn't speak highly of PHP as a language, just on how its deployment strategy is designed.

Re: OrmHate

#18
post #17
post #6

Earlier quoted context omitted.

There is nothing wrong with PHP - it runs multi-billion dollar companies and it is the most ubiquitous language on the web for a reason.

Because it has near-zero barrier to entry. That doesn't speak highly of PHP as a language, just on how its deployment strategy is designed.

I don't think Facebook or Yahoo chose PHP because it was easy to write.

Re: OrmHate

#19
post #3

"You have a relational mapping problem. 'I know', you say. 'I'll use an ORM.' You now have two problems." That just about sums up my experience with ORMs. Of course, like all things in the real world, experiences vary. However, I do think that generally, ORMs solve none of the difficult relational mapping problems and adds another layer of abstraction that complicates things like performance tuning to the point of ne…

The problem is there's plenty of trivial work for an ORM to do (mapping types, simple queries, etc). If you roll this yourself your implementation will be buggier than a major open source ORM.

Re: OrmHate

#20
post #4
post #2

For the same reason PHP gets so much hate - both are tools with valid uses, but because they make hard things easier for people, that means that people who have no idea what they're doing can do very bad things. Hating on a tool is ridiculous.

The core of fowler's article is, "what is the alternative to ORMs?" - and the answer is there isn't much other than rolling your own. This is not at all analogous to PHP where there is an abundance of alternatives to it's mediocre design. PHP isn't hated because of its concept - a "web-based scripting language". It's hated because it's done very poorly. Just like a lot of bad ORMs Fowler refers to.

Funny you should mention PHP. I suspect that a lot of the ORM hate comes from people forced to develop PHP and witnessing the epidemic of NIH syndrome among its web frameworks, every single one of which seems to come with its own half-assed ORM.
Post reply on HN