Hacker News new | ask | show | jobs
by davidw 1639 days ago
> broader set of strengths than Rails imo

What are those, in your experience? The BEAM platform is certainly better for concurrent work where you might be holding open something like a web socket. But other stuff...? I'm a pretty happy Erlang programmer and feel like I 'get' the functional programming aspect of things, but to me ActiveRecord just feels like such a great fit for DB work in that it makes the simple things really easy and intuitive, lets you do some more complex stuff, and gets out of your way if you just want to go to SQL. I don't have too much experience with Ecto. It feels like it "does the job", but is maybe not quite so quick and intuitive for basic/simple stuff like AR.

2 comments

Having worked with both ActiveRecord and Ecto, Ecto is consistently easier to reason about and change than AR. It feels closer to the DB without compromising composability, and better avoids surprises. Ecto is IMO one of the killer features of the Elixir ecosystem that is undercelebrated compared to the neat things that are rarely used.
Do you have any concrete examples that you're thinking of?

In particular, I found that having to include all the fields is kind of a PITA compared to AR. I also just find the mental model of an AR object to be really easy to think about in terms of the simple cases. Before save, after save, accessors, and just having methods available on the object all seem really intuitive compared to changesets. Not that I didn't figure those out in short order, they just seemed a bit clumsier. But I am not super deep into Ecto, either, so maybe I'm missing some places where it shines.

It's hard to beat Rails for "need to make a CRUD app in front of a DB". Phoenix is pretty close, though.

Where it really shines is anything beyond CRUD. I want to make my CRUD apps more dynamic, and build collaboration features into otherwise boring apps. LiveView makes it wickedly simple to do things like typeahead find: https://twitter.com/mrkurt/status/1434969788275691522

And Elixir + BEAM gives me reasonable plumbing for collaboration features. Even something as simple as presence makes CRUD apps more powerful.

So the broader set of Phoenix strengths aren't ActiveRecord vs Ecto. Phoenix helps me build a more powerful app because it has a broader set of strengths. And it's almost as good at Rails for just CRUD, so I don't give up much to get those features.