What ORMs have taught me: just learn SQL (2014)
The most cringeworthy thing I heard about ORM&#x27;s actually happened two weeks ago when I explained our use of a query builder rather than an ORM. The new senior developer was talking about speed (??? uhm… k...) and the benefit of being able to switch between PostgreSQL and... MongoDB. I just cringed up, didn&#x27;t know what to say. Using the same domain model in an RDMBS as a Document Store? I really didn&#x27;t know how to respond to that.<p>On the other side you have juniors, just starting development and working with an ORM&#x2F;ODM the first time. It&#x27;s not uncommon for them to spend years in development while learning very little SQL at all, hardly understanding the database (apart from what they learn in school). I don&#x27;t blame them. I hardly know TCP&#x2F;IP at all and still I write technology for it everyday. But ORMs are a more leaky abstraction; a lot of complexity is made easier by just switching to SQL.<p>More principal points:<p>- Why do we want to abstract away further from the most important part of the business: data. Data usually outlives the applications built on top of it.<p>- Best practice is to keep backend API&#x27;s stateless and requests short-lived. ORM&#x27;s promote the use of state. In client-side applications state is a much more interesting long-lived thing, but a backend API these days? It has actually become a lot simpler there since I&#x27;ve started doing development; few modern backend servers render views these days.<p>I understand why the author (re-)embraced stored procedures but I never will. Blame the overzealous PL&#x2F;SQL Oracle seniors I&#x27;ve met, god forbid any human bestows such complexity on it&#x27;s fellow colleagues. It&#x27;s also hard to automate tests for them and promote it through DTAP alongside an application, hence I keep putting all logic in the application.<p>I can imagine if the language and ecosystem are very strongly geared towards ORM you shouldn&#x27;t try to do anything else. That&#x27;s just painful. But in most languages other than Java and C# I&#x27;d make a good consideration if you really need&#x2F;want an ORM (coming from Java, I never took non ORM design seriously there, but perhaps I shouldn&#x27;t have).<p>Not sure where I&#x27;ll stand in a few years time on this… but for now just happy with plain old SQL and query builders.