News for hackers. Stuff that matters.
Re:Is ORM still an anti-pattern? by square_usual on Tuesday June 27, 2023 @04:42PM (#36498371)
ORMs are all problematic, but some are less problematic than others. Some years ago I started writing more Elixir with Phoenix and Ecto, and I quickly realized just how much better Ecto is when compared to ActiveRecord. I wrote about it back then [1] but the gist of is it: SQL > Query Builders with some ORM elements > ORM qua ORM, and the less you blur the boundary between your application and the database the better.

1: https://blog.shrikanthup.com/2021-12-04-ecto-data/

Re:Is ORM still an anti-pattern? by mmcclure on Tuesday June 27, 2023 @08:04PM (#36500471)
You say this in your post (and allude to it here), so not trying to be pedantic, but explicitly surfacing it here for other folks that don't click through: Ecto isn't an ORM.

I love Ecto. In my opinion, Phoenix has a lot of strengths, but Ecto is the superpower in that ecosystem.

That being said, at least _some_ of the brand of "problems" mentioned in the post can exist into the Ecto world. I've seen plenty of folks new to Ecto fall into N+1 queries using `preload` naively, so I'd argue it doesn't completely erase that blurred boundary. I also personally much prefer the level that Ecto sits at and think the tradeoffs are totally worth it.