|
|
|
|
|
by grim_io
246 days ago
|
|
I don’t get this at all, and I tried to understand it. I'm good at SQL. When necessary (maybe once a year), I can drop into pure SQL instead of Django ORM like it's nothing. The thing is, I can't imagine why I would ever want to. All these anti ORM comments read like they want to be as close to the DB as possible. This is not what I want. I don't care about guaranteeing the most efficient query, because it is never the bottleneck, not even close. I want to be as expressive as I can be in the business logic, and I don't feel like I am using pure SQL. |
|
SQL is the most high level language in common use. It abstracts away everything: Storage, memory, concurrency, and, most importantly, control flow. Complexity comes from complecting things, simplicity comes from decomplecting [1] things. SQL decomplects the what (data flow) from the how (control flow) which means less cognitive load, higher developer productivity and better maintainability.
In my experience, writing business logic in SQL results in fewer bugs and less code. I have replaced 50-line Java methods with 15-line SQL projections multiple times. With Python, the ratio is closer to 2:1, but it's still impressive.
And all of this without having to consider type impedance, eager versus lazy loading, result set mappings, second-level caching, dirty tracking, lifecycle management, OCC, or obscure savepoint bugs. Performance is just a nice, but welcome side effect.
[1] https://www.youtube.com/watch?v=SxdOUGdseq4