Hacker News new | past | comments | ask | show | jobs | submit login

SQLAlchemy is far superior to ActiveRecord if you already know SQL and write fairly complex queries. Once you get past a certain point, figuring out how to write or optimize a query in AR (or, to be fair, most other ORMs) tends to involve hunting down some obscure Rails-specific incantations, whereas SA maps pretty nicely onto SQL and doesn't try to offer as high of a level of abstraction. I've also found that it's easier to shoot yourself in the foot with ActiveRecord, performance-wise (though this has gotten much better over time).

The downside of SQLAlchemy is that it's less pleasant to use for simpler queries/tasks, so which ORM is better depends on the project. I've worked on codebases that never crossed that threshold, and ActiveRecord gave a consistently great developer experience. YMMV.




Is SQLAlchemy about equivalent to Arel in Ruby, then?


ARel is very roughly equivalent to SQLAlchemy Core[0], though I'd expect less complete and polished but I really don't know much of ARel.

[0] https://docs.sqlalchemy.org/en/13/core/tutorial.html




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: