r/programming • u/JohnyTex • Feb 22 '25
Scrap Your ORM—Replacing Your ORM With Relational Algebra
https://youtu.be/SKXEppEZp9M?si=wccXwllXm-0M-zOO
65
Upvotes
r/programming • u/JohnyTex • Feb 22 '25
23
u/rage_311 Feb 22 '25
I'm curious to know what his Python code, that implements this, looks like.
120
u/devraj7 Feb 23 '25
Is this another one hour video basically saying "Use an ORM that covers 90% of your requirements and lets you use raw SQL for the other 10%"?
32
u/oneMoreTiredDev Feb 23 '25
orm for simple queries (e.g. get by id) and inserts/updates/deletes, raw sql for anything more complex
you can even opt for compiled raw queries, some langs and frameworks provides that (golang's sqlc, node.js prisma typesql)
177
u/red_planet_smasher Feb 22 '25
Are we still debating the merits of ORMs versus raw SQL versus relational algebra? What year is this?
15
u/kthxb Feb 22 '25
Looks very similar to what you would write in e.g. GORM. I don't quite see the major differences and advantages to using any ORM?
55
u/vajeen Feb 23 '25
The best approach is an AI abstraction layer. You write all of your queries in natural language then pass it to a GPT to generate the target DB's query language.
In fact you can just define all of your code as business requirements and just trust that the LLM will generate working code. After all, LLMs can do the job of developers, right?
11
u/a-cloud-castle Feb 23 '25
No thanks.
4
u/Zardotab Feb 23 '25
🐹 Okay, you be the guinea pig. When it proves wonderful, our shop will adopt it.
4
u/tallesl Feb 23 '25
It would be so cool if the databases had some sort of DSL to query their structured table-like data. Like some sort of "structured query language".
Oh, wait.
27
u/extra_rice Feb 23 '25
Wow. This thread is full of edgelords who seem to get off the idea of rawdogging SQL in complex software systems, while deriding anyone who chooses any alternative.
8
u/suprjaybrd Feb 22 '25
yeah, no.
4
u/gobi_1 Feb 23 '25
Maybe people should watch the video before commenting.
Anyway, this is just another query builder. Nothing new under the sun.
2
u/tomekrs Feb 23 '25
But my ORM already offers a very good Relational Algebra capability. It's Rails' ActiveRecord
2
u/lcjury Feb 23 '25
Oh man, he exposed "don't expose all of SQL" as a con of ORM, and at the end of the video he exposes his option also has that problem...
Leaving you with: "This doesn't couple your code to your ORM". In my mind, this discussion about decoupling the ORM from your proyects ended around 2018, apprantely I was wrong...
2
u/nicheComicsProject Feb 24 '25
I'm surprised to see people still talking about ORMs. In my world, we dropped use of ORM probably 10 years ago.
The problem with ORMs is two fold:
The only thing I ever use an "ORM" for is, e.g. Linq has a fantastic static query builder. If my data is actually relational (or that representation makes the best trade off) then what I want is type safe SQL, not to pretend my data is some other format.
1
u/mpanase Feb 23 '25
Suggesting ORM people to learn Relational Algebra... is it a joke? You don't bother to learn SQL, and you gonna learn Relational Algebra?
Learn SQL, stop mocking around.
1
u/LowB0b Feb 23 '25
I mean JPQL and hibernate come with some overhead but at least you don't have to give a fuck about sanitizing.
Also, it works
1
u/RDOmega Feb 24 '25
Only people who complain about ORMs are sloppy developers who don't learn how to structure their applications.
1
u/dhlowrents Feb 24 '25
Here's a nice ORM for Java https://persism.io/
1
u/Long_Investment7667 Mar 04 '25
Does it mention anywhere that this is essentially.NET‘s LINQ ?
1
u/Algorhythmicall Feb 23 '25
Rails did this for active record with AREL a long time ago. I mostly do native sql now with simple type mapping, but AR is quite good. I have yet to see an ORM as good as active record.
1
u/mntzrk Feb 23 '25
ORMs offer so much more, lazy loading (sometimes bad), flushing DML-SELECT queries on commit etc.
-19
u/surrender0monkey Feb 22 '25
I don’t hire anyone that professes love for ORMs
-27
u/Fiduss Feb 22 '25
Does in 2025 anyone with experience still think that orms or anything else besides simple sql and repositories mapping to dtos are a good thing? I don’t!