What's wrong with ORMs
I was recently reading about F1, Google’s fault-tolerant distributed RDBMS and came across this neat little summary of what’s wrong with ORMs.
- Obscured database operations
- Serial reads
- Implicit traversal
Obscured database operations essentially means that when scanning code, you cannot easily tell which code is going to kick off a network round-trip to the database. If you care about writing code that performs well, it’s pretty important to know.
Serial reads are what many in my circles know as “potato programming”. When you have a loop, and something inside that loop is doing a query, that’s potato programming. Again, disastrous for performance.
Implicit traversal is doing unwanted joins and loading unnecessary data. ORMs tend to load up an object with all of its instance variables, which often means traversing the graph of references.
Anyway, this is a much handier answer to have than ‘google for “Vietnam of Computer Science”’, which is fascinating but rather lengthy. (See also Jeff Atwood’s summary).
For bonus points, these three things are also what’s wrong with Launchpad’s API.