News for hackers. Stuff that matters.
Re:Running GitHub on Rails 6.0 by tyre on Monday September 09, 2019 @04:13PM (#20921947)
ActiveRecord is the best ORM I've ever used, in any language, and I don't know of an engineer I've worked with who disagrees, regardless of their preferred stack. Using `merge` on two queries still blows my mind. I've been using SQLAlchemy lately and it's a daily reminder of just how many things AR got right.

Rails has its downsides (helloooooo memory usage!) but for getting up and running fast and having a full toolkit available to get the basics done, it's a pretty amazing project.

Re:Running GitHub on Rails 6.0 by RussianCow on Monday September 09, 2019 @05:55PM (#20922914)
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.

Re:Running GitHub on Rails 6.0 by faitswulff on Monday September 09, 2019 @08:31PM (#20924037)
Is SQLAlchemy about equivalent to Arel in Ruby, then?
Re:Running GitHub on Rails 6.0 by masklinn on Tuesday September 10, 2019 @02:08AM (#20925486)
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

Re:Running GitHub on Rails 6.0 by cortesoft on Monday September 09, 2019 @04:16PM (#20921979)
In fairness I haven't used ActiveRecord in a few years, but I really love the Sequel ORM for ruby over my previous experience with ActiveRecord. I feel like ActiveRecord can be a bit too magic for some of the more complicated things I have to do with my models.
Re:Running GitHub on Rails 6.0 by tsotpsstt on Monday September 09, 2019 @05:14PM (#20922551)
+1 for Sequel. I've decided to try Sequel instead of AR for new project 3 years ago. Never looked back, feels like a breath of fresh air. Hope it will gain more recognition in the Ruby community.
Re:Running GitHub on Rails 6.0 by pg_bot on Monday September 09, 2019 @04:20PM (#20922012)
I used to hold this opinion until I started using elixir's ecto library. However, I still do hold ActiveRecord in high regard.
Re:Running GitHub on Rails 6.0 by tyre on Monday September 09, 2019 @04:45PM (#20922286)
I love ecto as well. I love pure SQL and interfacing closer to raw data. Phoenix/Ecto is where I'd gravitate starting a new project (we used it in production at our startup) for many reasons including the simplicity of deployments.

For people getting started with engineering, AR is a nice wrapping/mapping of SQL => object oriented models. There's a mix of productivity, approachability, and feature set that puts AR ahead, for me, as a general use ORM.

I would agree, though, with a strong and experienced engineering team Ecto and Elixir are quite nice.

Re:Running GitHub on Rails 6.0 by dnautics on Monday September 09, 2019 @04:47PM (#20922308)
If nothing else ecto doesn't autopluralize. I suppose I have a small mind, but that always got under my skin.
Re:Running GitHub on Rails 6.0 by cglace on Monday September 09, 2019 @04:48PM (#20922313)
I've never found it hard to do anything with sqlalchemy and we write some pretty complex queries. Do you have any examples?
Re:Running GitHub on Rails 6.0 by steveklabnik on Monday September 09, 2019 @04:35PM (#20922180)
It's been a few years since I've been involved in Ruby and Rails, but back then, there was a lot of controvery over AR. Not because of the quality, which has generally been excellent, but over the pattern itself; see the pushback against "fat models" and towards "service objects" for this kind of debate.
Re:Running GitHub on Rails 6.0 by flukus on Monday September 09, 2019 @08:10PM (#20923906)
> ActiveRecord is the best ORM I've ever used, in any language, and I don't know of an engineer I've worked with who disagrees

Maybe it's morphed into a more general ORM in the 10+ years since I've touched it, but the active record pattern breaks down very quickly once you get beyond basic CRUD apps.