Remix.run Logo
hatefulheart 3 hours ago

I have seen many ORM enjoyers argue the point about “you can just use SQL!” but I have never once seen an ORM enjoyer allow it, much less do it themselves in an actual codebase. They will time and time again prefer you write 100 lines of Typescript/Python for what could be achieved with 15 lines of SQL.

jghn 2 hours ago | parent | next [-]

To make matters worse, most of the time I've successfully argued a project to just use SQL instead of an ORM, what has happened is that people over time built a home rolled ORM in the development language.

It's like people can't just let go.

hparadiz 2 hours ago | parent [-]

This is inevitably what happens every single time so just use an ORM and stop being stubborn.

jghn 2 hours ago | parent [-]

The problem is that "ORM" does a lot of heavy lifting as a term and can mean different things to different people. Like yes, obviously, one needs some sort of SQL -> data structure transition on the boundary (using "object" overfits to OOP!). But that can be extremely light weight. Let people write SQL, have a thin layer to pull the results back out into the appropriate data structures, and move on.

hparadiz 2 hours ago | parent [-]

Every good ORM lets you write SQL. Mine for example has a getByQuery and getByWhere as standard methods. An ORM isn't just writing queries for you it's also handling type casting from lang primitives to SQL and back. In 99% of crud rest apis there should be no need to write your own SQL though.

zadikian 2 hours ago | parent | prev | next [-]

And then the 100 lines of JS/Py ends up being way slower than the manual SQL, plus the autogen'd SQL part of it is slow, plus you can't even get the SQL query to profile without running the actual thing with prints.

hatefulheart 2 hours ago | parent [-]

You got it in one, small world huh?

pjmlp 2 hours ago | parent | prev | next [-]

Worse, that code will be executed on the receiving end, and waste a bunch of network traffic.

nfw2 2 hours ago | parent | prev | next [-]

The reason given to use raw SQL is for the performance not the perceived code clarity.

baq 2 hours ago | parent | next [-]

If you never used a CTE, maybe… The reason to use SQL is to get what you need out of a database. Performance is orthogonal to that.

hatefulheart 2 hours ago | parent | prev [-]

I’m not sure why you thought I meant code clarity and not performance? It’s clear in all cases the correct SQL query will be more performant.

Confused at what you’re evening trying to say here. Are you suggesting that 100 lines of application layer code is easier to understand than 15 lines of SQL?

airstrike 2 hours ago | parent [-]

The correct SQL query will be more performant than what? The correct ORM call will build the same correct SQL query.

ORM is ultimately SQL

hatefulheart 2 hours ago | parent [-]

So there is no CPU cycles for the ORM itself? That’s free?

7bit 2 hours ago | parent | prev [-]

Great anecdote. Doesn't validate your claim

hatefulheart 2 hours ago | parent [-]

Looks like I’m not the only one, check the thread.

7bit 2 hours ago | parent [-]

Still just anecdotes. Who cares about those

hatefulheart an hour ago | parent [-]

You’re on a forum where people share anecdotes, so presumably, you?

Are you dumb or are you just pretending? I’m going to guess the former!