33
Martin Fowler: ORM Hate
(martinfowler.com)
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev
I've never worked on a codebase where using ORMs wasn't better than rolling your own queries. What are people writing that they actually need the marginal performance gains? And even if that's worth it, why not just use raw queries in your critical paths?
Every time I have to write or modify raw SQL it feels like I'm throwing away all my static checking features and increasing the chance of bugs, because I have no idea of the query matches my schema or if it'll blow up at runtime.
Your last paragraph can be fixed even without an ORM though. Rust has libraries like diesel and sqlx that verify the sql in various ways.
Diesel is an ORM and sqlx requires a modern macro system, that many established languages lack.
This is kind of stretch to say though - it is not an ORM if you compare it to something like ActiveRecord. Diesel is just a DSL for writing SQL queries that are verified by the compiler.
I wouldn't say it requires using macros. You could definitely imagine verifying queries in the same way in languages without macros. But yea, this is one of the strengths of Rust I suppose.