ORMs Are a Lie We Tell Junior Developers So They Don't Have to Learn SQL
#Backend

ORMs Are a Lie We Tell Junior Developers So They Don't Have to Learn SQL

Backend Reporter
4 min read

Teaching ORMs first cripples developers by hiding database complexity. Start with SQL to build solid foundations.

Every time I see another developer struggle with a performance issue that could be solved in 30 seconds with raw SQL, I wonder: what have we done? We've created an entire generation of backend developers who think databases are magic boxes that respond to method chains.

Here's the uncomfortable truth: teaching ORMs first is like teaching someone to drive using only cruise control and lane assist. Sure, they'll get from point A to point B, but the moment something goes wrong, they're helpless.

The Comfortable Lie

ORMs promise productivity. They promise safety. They promise that you never have to think about the database layer again. These promises aren't just false—they're actively harmful.

When you use an ORM, you're not writing database queries. You're writing code that generates database queries. That extra layer of abstraction doesn't eliminate complexity; it hides it. And hidden complexity is the most dangerous kind.

I worked on a project where a single API endpoint was taking 8 seconds to respond. The ORM was generating 47 separate queries to fetch data that could have been retrieved with one well-crafted JOIN. The developer responsible had three years of experience and genuinely didn't understand why User.orders.items.categories was slow. The ORM made it look so simple.

What We're Actually Teaching

When we start junior developers with ORMs, we're teaching them that databases are implementation details. We're teaching them that performance is someone else's problem. We're teaching them to trust magic.

But databases aren't implementation details. They're the foundation everything else sits on. A poorly designed database will cripple your application no matter how clean your business logic is. A poorly understood database will generate bugs that are invisible until production load hits.

The N+1 query problem isn't an edge case. It's a fundamental misunderstanding of how relational data works. When your ORM lets you write user.posts.each { |post| puts post.comments.count }, you're not writing elegant code. You're writing a database destroyer.

The Performance Trap

ORMs optimize for developer convenience, not database efficiency. They generate safe, generic SQL that works in all cases but excels in none. Your ORM will happily SELECT * from a table with 50 columns when you need just 2. It will use subqueries where JOINs would be faster. It will generate WHERE clauses that can't use indexes.

And because it's hidden behind a friendly API, you won't notice until it's too late. I've seen production systems where adding eager loading (.includes() in Rails, .Include() in Entity Framework) improved performance by 95%. That's not optimization—that's fixing fundamentally broken data access patterns.

SQL Is Not That Hard

The real reason we reach for ORMs isn't complexity. SQL is not a difficult language. Basic CRUD operations take minutes to learn. JOINs take an afternoon. Window functions take a weekend.

The real reason is that SQL feels old-fashioned. It doesn't look like the modern languages we use everywhere else. It doesn't have method chaining or fluent interfaces. It looks like what it is: a specialized tool for a specific job.

But specialized tools exist for good reasons. You wouldn't use a Swiss Army knife to build a house, and you shouldn't use an ORM to handle complex data relationships.

When ORMs Make Sense

I'm not saying ORMs are always wrong. They excel at simple CRUD operations on single tables. They handle migrations well. They provide useful abstractions for connection pooling and transaction management.

But they should be tools in your toolkit, not the foundation of your data layer. Use them for the easy stuff. Drop down to SQL for the complex stuff. And always, always understand what queries your ORM is generating.

Teaching SQL First

Imagine starting junior developers with SQL instead of ORMs. They would:

  • Understand exactly what their code is doing to the database
  • Write more efficient queries from day one
  • Debug performance problems with confidence
  • Design better database schemas
  • Ask the right questions about data access patterns

Would they be slower initially? Maybe. But they'd be building on solid foundations instead of convenient abstractions.

The Way Forward

Stop treating SQL like assembly language. It's not a low-level detail you graduate away from. It's a powerful, expressive language for working with relational data.

Start new developers with SQL. Teach them to write queries by hand. Show them how to read execution plans. Make them understand indexes. Then, and only then, introduce ORMs as productivity tools.

Your junior developers will thank you when they're not debugging mysterious performance issues at 2 AM. Your database will thank you when it's not processing 50 queries instead of 1.

Most importantly, you'll have developers who understand their tools instead of just using them. And that makes all the difference.

What You Can Do Right Now

If you're a senior developer, stop accepting "the ORM handles it" as an answer. Require your team to explain the SQL their code generates.

If you're learning, spend a week writing raw SQL before you touch an ORM. Create tables, insert data, write JOINs. Understand what you're abstracting away.

If you're hiring, ask candidates to write a SQL query during interviews. Not a trick question—just a basic JOIN. You'll be shocked how many can't do it.

The lie we tell junior developers isn't protecting them. It's crippling them. Time to tell the truth.

Build seamlessly, securely, and flexibly with MongoDB Atlas. Try free.

Comments

Loading comments...