this post was submitted on 29 Mar 2024
13 points (88.2% liked)

SQL

451 readers
1 users here now

Related Fediverse communities:

Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
 

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?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 10 points 4 months ago* (last edited 4 months ago) (2 children)

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.

[–] [email protected] 2 points 4 months ago (1 children)

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

[–] [email protected] 1 points 4 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.

[–] [email protected] 2 points 4 months ago

Linq

LINQ is remarkable.