4 ms·
When I started web work ~9 years ago, it was with Rails and ActiveRecord, which turns out to be incredibly good for basic queries and pretty basic apps. So good
by jackschultz 7y ago
When I started web work ~9 years ago, it was with Rails and ActiveRecord, which turns out to be incredibly good for basic queries and pretty basic apps. So good to the point where I never bothered to go too far into SQL until years later, which was a mistake.
When doing work in python, I don't feel it has a comparable ORM, to where I kind of write my own files that have things like finders and updaters and creators. In most cases, I've found it's much better than SQLAlchemy. Dealing with joins, and things like math, meaning averages, sums, distributions, division, is so much better to be done in the query rather than more basic queries and looping through the results.
There are of course cases like injections to look at, but lots of things I have are calculations of data and showing it, so we're able to handle it with raw queries. Also, ActiveRecord has ways to enforce no injections.
In lots of cases, we've found that using an ORM to start, finding slowness, and moving towards raw queries is a great way to go.
- thenewnewguy 7y agoCurrent rails developer here, I've found that using ActiveRecord for basic queries and moving to SQL for more complex stuff to be a very good combination. I agree that ORM users should learn SQL, but SQL and an ORM are not mutually exclusive.
- RangerScience 7y agoYep, also current rails dev here and this is also what I do :) Learning SQL with an ORM does remind me a bit of learning memory management with a garbage collector: helps you make better choices as to how you put things together, even if you never directly use the know-how.
- look_lookatme 7y agoGood to see y'all Rails developers out there, enjoying work and getting things done.
- RangerScience 7y agoAyup :) Rails ain't dead, it's just mature.
- meesterdude 7y agocurrent rails dev here, i've found ripping out the custom SQL and replacing it with ORM equivalents offers the best performance and readability short of custom Postgres functions. The state of ORM in rails of 2014 vs 2019 is a big leap.
- look_lookatme 7y agoWe use ActiveRecord, which, from my perspective is a good ORM. It's very simple. If you are diligent you can use pluck and count and a ton of other features to ensure you are selecting only what you need. It's easy to drop down to sql in partial form or in the full form. We tend to not get too crazy with AREL. In particular I like that it behaves way better using surrogate primary keys (serial id column) instead of natural primary keys... it just answers that question for you that would otherwise result in bike shed conversations. We minimize logic in the AR models, instead those are in glue objects and this pattern works real well. AR models are mostly there for describing relationships in the code and doing data validations in the code on top of CRUD operations.