(no title)
cqqxo4zV46cp | 1 year ago
I’ve read a lot of criticisms of ORMs, as I’m sure everyone else has. Some of them are certainly valid criticisms that are immovable and just inherent in what an ORM tries to do. Some of them just seem to be caused by not very many ORMs being good, and the writer not having used one of the better ones.
Swizec|1 year ago
Although over the years my code trends more and more towards `.rawSql` or whatever equivalent exists. Even for the simple stuff. It’s just so much easier than first thinking up my query then bending over backwards three times to make it fit into the ORM’s pet syntax.
Plus raw sql is so much easier to copypasta between different tools when you’re debugging.
And before you say “but sql injection!” – that’s what prepared statements/parametrized queries are for.
djeiejejejej|1 year ago
Once you get sufficiently familiar with some paradigm the training wheels can come off.
“Raw” SQL is already an abstraction. Over time all the implicit magic will get on your nerves. Trying to shoehorn two completely different worlds into one abstraction is not worth it: you get to learn today’s untransferable funky ORM syntax and idiosyncrasies while losing sight of the actual skill that matters long term which is SQL itself.
I concede however that handling of SQL, the field names, the relations, is annoying. But it’s core to the problem you are probably solving (some form of CRUD). Plumbing is annoying but as a plumber I’d say get used to it instead of wishing to be dancer.
I notice this in other aspects of my work as well. When I switched away trom desktop environment to terminal I had the same feeling. It’s easier, less hassle, less wonky abstractions, more direct. Completely counter to what popular culture is telling me.
wsc981|1 year ago
But the team chose EF due to it supposedly being easier to integrate with whatever database the customer might be using and that seems like valid reasoning.
Izkata|1 year ago
I started using Django on I think version 1.2 or 1.3 in 2011, back when it didn't have database migrations and you had to use a library like South for it. Even then, as an ORM/query language it was apparently better than what other languages have now.
simonw|1 year ago
That branch merged on May 1st 2006: https://www.djangoproject.com/weblog/2006/may/01/magicremova...
I've long found Django's commitment to not breaking too much at once inspiring. The release notes and upgrade guides are really solid.
choilive|1 year ago
wg0|1 year ago
If you started from Rails and ActiveRecord, you're probably not be very appreciative of Django's ORM.
bitexploder|1 year ago
greenie_beans|1 year ago
malux85|1 year ago
Define the object, hook it to a view, use our custom permission class, done.
GET, POST, PATCH, DELETE all urls, filtering, pagination, search, ordering, complex multi-org multi-user object permissions handled automatically. Need custom logic? Just overwrite method.
It’s a productivity superpower, sure there’s a lot to learn but that’s the price you pay for the tools that make you hyper productive
nprateem|1 year ago
murkt|1 year ago
SQLAlchemy is leagues above and beyond Django ORM. I can’t say I have nightmares from dealing with it, but it certainly was not pleasure. A bit too much magic here and there, not flexible enough and provokes too much bad practices. Re-defining save() methods to do a lot of work, anyone?
The best “orm” that I’ve ever used was not an ORM but a query builder — HoneySQL from Clojure. That one is fantastic. No ORM bullshit, no extra data loaded from DB, no accidental N+1 queries. Not reading docs on how to do a GROUP BY, everything’s just easy to write.
Frankly, we often use SQLAlchemy as just a query builder too. Makes life so much easier.
1propionyl|1 year ago
The lack of support until very recently (and it's still lacking) for views is the main knock.
winrid|1 year ago
I'm rewriting a large Django project in Java (quarkus + jooq), because it's at the point where I need a type system now, but it still has a place in my heart.
BarryMilo|1 year ago
JodieBenitez|1 year ago
I had the "pleasure" to use Doctrine once. Never again !
vandahm|1 year ago