Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> ORMs are the devil in all languages and all implementations. Just write the damn SQL

I'm re-evaluating this again. I used to be all-in on ORMs, eventually became annoyed with the shortcomings and the performance problems, but am realizing the disadvantages of foregoing them as well.

* ORMs Bad: ORMs often lead to deep object graphs and tight coupling if you don't know what you're doing / don't factor the model properly. This has serious performance implications.

* ORMs Good: you get a unified, consistent view of all of your data on which you can enforce invariants in a holistic way.

* Only SQL Good: you can easily return and operate on only "slices" of the data, which is great for performance and rapidly iterating on features.

* Only SQL Bad: because you're only operating on "slices", you don't get a unified view of the data on which you can declare invariants. You can declare invariants on the slices and then stitch all of the properties together in your head to make sure you covered everything important (and write what tests you can to validate this), but this is error-prone and less necessary with ORMs.

So yeah, there's no single, clear winner here yet.



> enforce invariants in a holistic way

This sentence is golden, it advances the bullshit bingo score better than the rest.

But honestly, in SQL the invariants should be constraints and triggers, enforced by the DB, not just by the application layer.


Constraints and triggers are more limited than the kinds of invariants you can enforce in code.


Only by convention. You can write anything in a PL/SQL function, and that function can be called in a trigger.

Really, I can't imagine anything that can't be put in a trigger.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: