4 ms·
One of the biggest problems with ActiveRecord (the ORM in the article) is that it uses extremely obtuse names for extremely common methods. There are three diff
by strken 8y ago
One of the biggest problems with ActiveRecord (the ORM in the article) is that it uses extremely obtuse names for extremely common methods. There are three different methods for finding how many things meet a given criteria[0], and none of them do the same thing. There are three different methods for loading data from an associated table[1], and none of them do the same thing either. None of the method names explain how the function is implemented or whether it's going to hit the database.
This is a problem that goes beyond the usual ORM antipatterns and bad database designs and becomes its own special kind of hell, because it makes code far harder to reason about and thus far harder to review, in a way that I don't remember encountering in Hibernate, Gorm, or anything else.
[0] count, length, and size
[1] includes, preload, and eager_load
- grey-area 8y agoYes there are a few problems with ActiveRecord; it has been well used and has accreted lots of similar functions (a victim of its own success), and also it doesn't make it crystal clear when you are hitting the database. IMO ORMs should be simple, unsurprising, and only have one or two methods which actually execute the sql and fetch data - they are there to make it simpler to build queries and map rows to objects, not to blur the line between fetching and manipulating data.
- AsyncAwait 8y agoThis is mostly due to its popularity and various people needing different use cases, the long-time maintainer is now working on a mach cleaner ORM for Rust, called Diesel[1]. 1 - http://diesel.rs http://diesel.rs
- mullsork 8y agoCompile time SQL query checks... amazing! I've been trying to find a similar library for a while. Thanks for linking
- matwood 8y agojOOQ for Java does something similar. It's so good, I'm likely stuck with Java on the backend until I stop using RDBMs.
- lukaseder 8y agoHey Mat, thanks for spreading the love. Hope you never stop using RDBMS! Fancy a couple of jOOQ stickers? :)
- matwood 8y agoI wouldn't use the stickers, so they would be wasted. Just keep making jOOQ a great to use library. :) And while I have you here...your blog posts are always great and very informative. It's interesting to see the differences between RDBMSs (I really only have experience with MSSQL/MYSQL some PG), and how they do one thing or another.
- lukaseder 8y ago> Just keep making jOOQ a great to use library. :) Will do! Thanks for the nice words about the blog.
- acdha 8y ago> This is a problem that goes beyond the usual ORM antipatterns and bad database designs and becomes its own special kind of hell, because it makes code far harder to reason about and thus far harder to review, in a way that I don't remember encountering in Hibernate, Gorm, or anything else. I feel like this brings up an annoying cultural problem in tech wgere developers hit intermediate skill levels and feel the need to proclaim their expertise by writing something in the you’re-doing-it-wrong genre but don’t have the breadth of experience to realize that they’re over-generalizing and so they go from “ActiveRecord has this problem” to “ORMs are bad” without asking whether anyone else has it better. I’ve read tons of similar posts where e.g. Java proved that exceptions, OOP, or static typing were bad or Twitter proved you shouldn’t use Rails.