My students struggle a bit with ActiveRecord for Sinatra and Rails, but they eventually get it.
However, they completely burn out on Sequelize for Node.
To my mind, the biggest difference between Sequelize and AR is that AR is synchronous, whereas Sequelize is not.
Consider:
# ActiveRecord
@post = Post.find(2)
render json: @post
// Sequelize
Post.findById(2).then(function(post){
response.json(post);
});
For small actions like this, the difference is still visible but it doesn't look so bad. With more complicated queries, it's easy to find yourself in callback hell.
So my question is: Why is it OK for ActiveRecord to be synchronous, but bad for a JS ORM to be synchronous?
I understand the disadvantages of synchronous vs. asynchronous. But the disadvantages of synchronicity don't really seem to be hurting ActiveRecord.
The difficulty with Sequelize isn't just that you have to write .then(function(){})
a thousand times; it's also that understanding how callbacks work at all takes a good amount of comfort with Javascript, and since Sequelize is the primary relational ORM for Node, it makes Node much less approachable to beginners. One might say "beginners shouldn't be using Node," but Rails has achieved a tremendous amount of success due to endeavors to make it approachable to novice developers.