Is there a programming language specifically designed for interacting with SQL databases that avoids the need for Object-Relational Mappers (ORMs) to solve impedance mismatch from the start?

If such a language exists, would it be a viable alternative to PHP or Go for a web backend project?

  • @pixxelkick@lemmy.world
    link
    fedilink
    10
    edit-2
    8 months ago

    No matter how you tackle this, your front end likely communicates in json and your database in sql.

    At the crux of it, your backend has the job of translating between the two without openly exposing the database to the front end (unless security truly doesn’t matter for your app)

    There’s no easy way to get around the fact you simply just have to write logic to mediate between those two languages.

    The best way I use to avoid mismatch problems between BE<->DB is I use Code First Entity Framework Core as my ORM, letting my EF Core spec act as the source if truth fir my db schema via automated EF migrations.

    This means the only way you get a mismatch is due to merge conflicts not being resolved properly if 2 devs both mutate the db schema at the same time.

    C#'s Linq is also the closest first class API I have seen that very closely mimics sql.

    I genuinely find Linq queries on Entity Framework easier to write and read than sql.

    • @eluvatar@programming.dev
      link
      fedilink
      28 months ago

      Yeah Linq is truly unique in programming languages. The fact that I can write a where clause how I would in normal code and it just translates it into SQL is so much nicer than some DSL for filtering

      • @pixxelkick@lemmy.world
        link
        fedilink
        18 months ago

        100%, the extremely 1:1 way that c# translates into sql is prolly the closest to what OP wants, I’ve tried a variety of ORMs and EF Core us hands down the best I’ve used.

        The fact it doubles as a DB Schema manager and migration engine is just icing on the cake. All my database related needs in one spot.

    • @veer66OP
      link
      English
      28 months ago

      Linq

      LINQ is remarkable.