←back to thread

873 points belter | 1 comments | | HN request time: 0.373s | source
Show context
imjonse ◴[] No.42947407[source]
> ORMs are the devil in all languages and all implementations. Just write the damn SQL

It depends on what you're writing. I've seen enough projects writing raw SQL because of aversion to ORMs being bogged down in reinventing a lot of what ORMs offer. Like with other choices it is too often a premature optimization (for perf or DX) and a sign of prioritizing a sense of craftsmanship at the expense of the deliverables and the sanity of other team members.

replies(8): >>42947752 #>>42947978 #>>42948317 #>>42948504 #>>42953164 #>>42954817 #>>42956074 #>>42956308 #
qaq ◴[] No.42947752[source]
It's not so much optimization but experience that on any sufficiently large project you gonna run into ORM limitation and end up with mix of ORM and direct queries. So might as well...
replies(2): >>42948245 #>>42954198 #
The_Colonel ◴[] No.42948245[source]
Starting with raw SQL is fun. But at some point you find out you need some caching here, then there, then you have a bunch of custom disconnected caches having bugs with invalidation. Then you need lazy loading and fetch graphs. Step by step you'll build your own (shitty) ORM.

Same thing for people claiming they don't need any frameworks.

replies(4): >>42948519 #>>42950241 #>>42951262 #>>42953407 #
wesselbindt ◴[] No.42948519[source]
> you find out you need some caching here, then there

Forgive my ignorance, but how do ORMs help with adding caching? Or are you implying they obviate or reduce the need for caching?

replies(2): >>42948686 #>>42948792 #
ivan_gammel ◴[] No.42948686[source]
They do caching themselves so that some of your queries via ORM won’t hit the actual db.
replies(1): >>42949394 #
capitainenemo ◴[] No.42949394[source]
So, given the main issue with ORM is the object/relational part... (https://web.archive.org/web/20160301022121/http://www.revisi...)

Why is caching not a feature in DB connection pools? I mean, most databases have it on their side, why not have it as an option for the same query sets prior to hitting the db, with configurable invalidations? Or is it, and I've just never thought to look for it.

replies(2): >>42949808 #>>42952224 #
ivan_gammel ◴[] No.42952224[source]
That would be a result set layer, not a connection pool. Could make sense if you worked with rows, but if you use ORM, why mapping cached row again and again? ORMs cache hydrated objects, which seems to be more efficient.
replies(1): >>42953337 #
1. capitainenemo ◴[] No.42953337[source]
Yeah, it was more to see if there were any benefits to an ORM that could be used without the, well "ORM" part :)