5 ms·
I've always said: "ORMs are for people who don't know SQL!"
by vladsanchez 10y ago
I've always said: "ORMs are for people who don't know SQL!"
- pixie_ 10y agoORMs are not for people who don't know SQL. The secret to using an ORM is knowing exactly the SQL it will generate underneath. The advantage to using one is static typing as well as writing orders or magnitude less code than SQL. As well as orders of magnitude more understandable code than the equivalent SQL. If you work on heavy enterprise applications the ORM can be your best friend or worst enemy. It comes down to knowing the tool you're using inside and out. It will make you much more productive in the long run. And sometimes yea, you need straight SQL or a stored proc to get the job done. That's OK.
- bdcravens 10y agoI began programming in languages where SQL was a requirement in 1999; only in the past 3-4 years have I use ORMs. I often write a lot of raw SQL, but I find a well written ORM statement communicates intent more quickly.
- spriggan3 10y ago> I've always said: "ORMs are for people who don't know SQL!" False. To use an ORM you must know and understand data modelling and the Entity/Relationship model. I'd say, people who don't like ORMs are often those who don't understand that model. If you do understand it, then you know that relationships can be represented 100% by code in an OO language, thus completely automated. Why bother writing your own hydrators for each entity when you can model them directly in a library? it doesn't make a codebase more maintainable or readable. Furthermore you could have an ORM that uses SQL directly for queries, and still eagerly resolve relationships. It's just not practical, that's why ORMs often come query builders. That is the thing that abstracts SQL, not an ORM per say. ORMs only deal with relationships between entities. Query Builders build SQL queries.
- mb_72 10y agoThis doesn't ring true for me, at least - I've been programming professionally (using SQL) since the mid-90s, and these days very much appreciate the time-savings that ORMs (on Windows, for the most part) provide. With my favourite ORM - XPO from Developer Express - there is a decent tool for monitoring queries and sessions, and if I need to I can write custom SQL to improve performance (which almost never happens). Another important point is that it's, IMO, much easier to maintain ORM-based code, and another programmer coming along after me can more easily get started on understanding what I've implemented. Once place I worked in the past we had a 'SQL guru' who wrote these massively complicated SQL queries that could be understood by no-one by him.
- jsmeaton 10y agoLike the others below/above I agree that you should certainly know SQL if you're going to use an ORM. ORMs can be a really great tool if you use them correctly. More to your point, I think the problem is the vast number of developers using ORMs without knowing SQL and running into big problems with correctness and performance.