For anything complex, definitely. For anything simple, eh. It also feels to me like he's talking about a specific ORM - I know ActiveRecord has it's fair share of issues, but from what I know of AR usage and implementation, it either doesn't do what he's (legitimately!) complaining about or does do it in the way he's suggesting.
What ORMs have taught me: just learn SQL (2014)
31–40 of 654 posts
Re: What ORMs have taught me: just learn SQL (2014)
#32ORMs lure you in with a false sense of neat abstraction. They have nice intuitive examples on their home pages. But then you use them in the real world, doing gnarly queries, and you realize that doing anything powerful and fast in the ORM requires its own completely separate abstractions, which are often difficult for the uninitiated to follow. It's also often a big pain to debug the raw SQL that gets compiled after…
You don't use ORMs for gnarly queries -- that's not what they are for! They are for making manipulating the entities easier -- reading the data out of the database in a way that makes easy to modify. You can (and should) use them for simple queries. You have a list of entities you want to query and filter, that's going to be fine. Joins are fine. But if you're doing some complex analysis, an ORM is the wrong tool. Th…
Re: What ORMs have taught me: just learn SQL (2014)
#33My personal gripe about ORMs is that they have two main usage patterns, and each of them has major drawbacks. The first pattern, common in frameworks like Django, is to cram the business logic into the ORM instance objects. This creates a tight coupling between the two separate concerns (business logic and data persistence), and will cause problems as soon as the two structures deviate from each other. The second pat…
For the second, I don't see how skipping the ORM avoids that duplication. Presumably you still need to map your database fields to object attributes.
Re: What ORMs have taught me: just learn SQL (2014)
#34If they had just used basic sql it would be much easier to refactor.
Re: What ORMs have taught me: just learn SQL (2014)
#35Are ORMs leaky abstraction? Absolutely. Is this the reason to avoid them? Not even slightly. ORMs provide plenty of ergonomic benefits over SQL.
Re: What ORMs have taught me: just learn SQL (2014)
#36Re: What ORMs have taught me: just learn SQL (2014)
#37"Any sufficiently complicated program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of a decent ORM."
ORMs are hard for a reason. Using an ORM doesn't mean you can't or shouldn't use plain SQL where the situation calls for it. You can mix and match perfectly fine.
[1] https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule Edit: typo.
Re: What ORMs have taught me: just learn SQL (2014)
#38SQL just isn't composable. I know this article is old, but these days it's not black and white. In the space between ORM and raw SQL there are things like AREL which can save a ton of dev effort without the "impedance mismatch".
Re: What ORMs have taught me: just learn SQL (2014)
#39Earlier quoted context omitted.
You don't use ORMs for gnarly queries -- that's not what they are for! They are for making manipulating the entities easier -- reading the data out of the database in a way that makes easy to modify. You can (and should) use them for simple queries. You have a list of entities you want to query and filter, that's going to be fine. Joins are fine. But if you're doing some complex analysis, an ORM is the wrong tool. Th…
If the argument is that it's the right tool for simple jobs, then by definition it won't save a lot of effort.
Re: What ORMs have taught me: just learn SQL (2014)
#40ORMs lure you in with a false sense of neat abstraction. They have nice intuitive examples on their home pages. But then you use them in the real world, doing gnarly queries, and you realize that doing anything powerful and fast in the ORM requires its own completely separate abstractions, which are often difficult for the uninitiated to follow. It's also often a big pain to debug the raw SQL that gets compiled after…