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”

  • Eager Eagle@lemmy.world
    link
    fedilink
    English
    arrow-up
    28
    ·
    edit-2
    2 days ago

    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.

    • ExLisper@lemmy.curiana.net
      link
      fedilink
      arrow-up
      3
      ·
      16 hours ago

      Couldn’t agree more. ORM helps in some places and is extremely easy to skip if needed. I think most comments saying that ORM is an overkill are just from people fighting everything that’s new just because it’s new. Not that ORM is that new, some people are just still stuck in the 90s.

    • OldMrFish@lemmy.one
      link
      fedilink
      arrow-up
      1
      ·
      16 hours ago

      After working on a few different projects, I’ve always ended up using ORM for normal operations and Stored Procedures for the complex stuff.

      If using MS products, the Database project type in Visual Studio even adds some basic static checking to SQL to help you out a little.

      Had the pleasure of taking over maintenance of a moderately complex application with a data access layer based entirely on Stored Procedures once - that was fun…

    • criss_cross@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      2 days 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.

    • SorteKanin@feddit.dk
      link
      fedilink
      arrow-up
      10
      arrow-down
      1
      ·
      2 days 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.

        • SorteKanin@feddit.dk
          link
          fedilink
          arrow-up
          1
          ·
          16 hours ago

          Diesel is an ORM

          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.

          sqlx requires a modern macro system

          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.