this post was submitted on 23 Mar 2026
19 points (91.3% liked)

Programming

26211 readers
468 users here now

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

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
 

This is a pragmatic piece of Fowler on the rather dry topic of Object-relational mappings - in short, the attempt to marry an object-oriented code base with a relational data base.

Usually you'd get enough early success to commit deeply to the framework and only after a while did you realize you were in a quagmire - this is where I sympathize greatly with Ted Neward's famous quote that object-relational mapping is the Vietnam of Computer Science

What Fowler refers to here, is Ted Neward's article "The Vietnam Of Computer Science"

top 27 comments
sorted by: hot top controversial new old
[–] eager_eagle@lemmy.world 17 points 1 day ago* (last edited 1 day ago) (2 children)

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.

[–] SorteKanin@feddit.dk 8 points 1 day ago

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.

[–] criss_cross@lemmy.world 2 points 1 day ago

I worked in a codebase at a FAANG company that didn’t have an ORM and it was the most miserable thing to write and code review. Constantly there would be bugs in queries and types. I missed having an ORM so much.

[–] Ephera@lemmy.ml 5 points 1 day ago

Yeah, this is one of those issues that I feel separates the seniors from the, uh, less experienced seniors. (Let's be real, as a junior, you know jackshit about this.)

Knowing when to use an ORM, when to use SQL vs. NoSQL, all of that is stuff you basically only learn through experience. And experience means building multiple larger applications with different database technologies, bringing them into production and seeing them evolve over time.

It takes multiple years to do that for one application, so you need a decade or more experience to be able to have somewhat of an opinion.
And of course, it is all too easy to never explore outside of your pond, to always have similar problems to solve, where an SQL database does the job well enough, so a decade of experience is not a guarantee of anything either...

[–] cecilkorik@lemmy.ca 11 points 1 day ago (2 children)

Two choices always seem to end up as the fate of any large scale, long-term developed database application. Either you use an ORM, or you build your own piece by piece. I know which one makes more sense to me.

[–] Maestro@fedia.io 4 points 1 day ago (1 children)

Same goes for any application that are proud to use "no framework". It just means that you partially implemented your own poorly documented half-assed framework.

[–] uuj8za@piefed.social 2 points 1 day ago (1 children)

It's a little more nuanced than that.

I will gladly write my own small, half-assed framework that I 100% know, can reason about, can debug, and can extend to fit my requirements. I will gladly pass on a fat-assed, bloated framework with a million dependencies, where I only need a few features, and where if I need something that isn't offered by the framework I have to submit a PR or add some janky-ass workaround.

[–] Maestro@fedia.io 1 points 1 day ago (2 children)

That is fine for your personal projects. It stops being fine as soon as you need to hire extra people and grow the team.

[–] Tempy@programming.dev 3 points 1 day ago

Does it, if you can work on the normal application code, there's no reason you can't work on the lower levels of applications. It's all just code. Ramp up might take a bit more time, but I wouldn't expect horrendously so. As long as your patterns make sense and what is there is written well enough and is not a spaghetti monster in the making, any one should be able to pick it up.

[–] inzen@lemmy.world 2 points 1 day ago* (last edited 1 day ago)

Why though?

Or using pure sql with hibernate substitutions and at most the columns fields at the entities for deserialization, instead of using a full orm (when inserting, hibernate does a select to update the entity, but this is because hibernate is bad, why the hell it would need to do that?).

Life is hard on java, jooq and other ones are a no no at my job, blaze persistence seems cool, but it's still slow, panache is just "magic" like hibernate.

I love asking new hires about ORMs. If they don't have anything bad to say about them I know they've never used them.

[–] e8d79@discuss.tchncs.de 5 points 1 day ago* (last edited 1 day ago)

I consider the ORM hate uninformed and misguided at best. Just like any other technology not all of them are created equally there are better ones and worse ones. I have used Entity Framework Core for years and have almost no complaints but If I only knew ORMs like NHibernate then I might have a different opinion.

[–] moonpiedumplings@programming.dev 4 points 1 day ago (2 children)

I like ORM's because they prevent sql injection. Mostly. Sql injection is a really bad vuln that's nowhere near as ubiqitous as it used to be for every php app, and that's partly due to ORM's.

[–] FizzyOrange@programming.dev 11 points 1 day ago (1 children)

You don't need ORMs to prevent SQL injection. Prepared statements have existed for decades.

[–] moonpiedumplings@programming.dev 2 points 1 day ago (1 children)

That's what I thought too: https://programming.dev/comment/22854391

But it seems to be possible to still do them wrong.

[–] Kissaki@programming.dev 4 points 22 hours ago

If you don't use the parameter functionality of prepared statements, yeah. That also means you don't use a prepared statement, you construct varying sql strings and prepare varying "prepared" statements.

[–] CameronDev@programming.dev 2 points 1 day ago

It's a bit sad that sql injection is still a thing. It's been a known problem for decades, and developers keep itching to reinvent the vulnerability over and over...

[–] FizzyOrange@programming.dev 3 points 1 day ago (2 children)

ORMs are a pain and so is hand rolling SQL queries and doing the mapping manually.

I definitely think there's scope for NoSQL databases where the database "shape" matches the normal struct style of programming languages. Kind of like how JSON does and XML doesn't.

But it seems like all we got was MongoDB and Firebase which are both shit.

Are there any good NoSQL databases? MongoDB and Firebase don't even have schemas.

[–] Maestro@fedia.io 4 points 1 day ago (1 children)

The real problem is that most data is inherently relational, and trying to force it into a document database is just as problematic as ORMs are.

[–] FizzyOrange@programming.dev 1 points 13 hours ago

I don't see why you couldn't have relations in a object model database. Just allow fields that are references to other objects or their keys.

Postgres jsonb?

[–] hperrin@lemmy.ca -1 points 1 day ago

I’m starting to think more that I shouldn’t call my library, Numph.js, an ORM. It technically is one, but it’s very different than other ORMs. A lot of the stuff he’s talking about here doesn’t apply to Nymph (for better or for worse). I just don’t know what to call it though.

[–] Olap@lemmy.world 0 points 1 day ago (3 children)

Having seen what the ORM hate leads to. Just use the ORM folks. Far better in the long to do so! Nothing has come close to ActiveRecord imo in Typescript or Python sadly. Unless anyone has a library or two I should check out?

[–] lukalix98@programming.dev 1 points 17 minutes ago

Jooq is cool if you happen to use Java.

[–] hperrin@lemmy.ca 1 points 1 day ago

You can check out my library, Nymph.js. It’s what powers Port87.

Unfortunately, I don’t have a whole lot of open source code showing how to use it, since it was developed specifically for Port87, which isn’t open source. But there are test files that show how to use it.

[–] HaraldvonBlauzahn@feddit.org 1 points 1 day ago

Haven't tried it, but functional programming methods (as in Clojure) combined with Datomic / Datalog sound interesting. It is said to be quite good.