Live data from Hacker News

Django: One ORM to rule all databases

paulox.net

81–85 of 85 posts

Re: Django: One ORM to rule all databases

#81
post #80
post #78

Earlier quoted context omitted.

> How? Stored procedures? Not neccesarily. jOOQ[1] and sqlc[2] are great options if you don't like stored procedures, but for a small app or a prototype, just having plain SQL strings in your app is fine. My point isn't that the code has to be stored in the database, but rather that the processing happens in one place where your data is stored and your middle tier just gets the results. Pure, stateless data. This mea…

I don’t get this at all, and I tried to understand it. I'm good at SQL. When necessary (maybe once a year), I can drop into pure SQL instead of Django ORM like it's nothing. The thing is, I can't imagine why I would ever want to. All these anti ORM comments read like they want to be as close to the DB as possible. This is not what I want. I don't care about guaranteeing the most efficient query, because it is never t…

Again, performance is not my point. If you want maximum performance, use a low-level key-value store, hence my VSAM analogy. On the contrary, for me it is about simplicity.

SQL is the most high level language in common use. It abstracts away everything: Storage, memory, concurrency, and, most importantly, control flow. Complexity comes from complecting things, simplicity comes from decomplecting [1] things. SQL decomplects the what (data flow) from the how (control flow) which means less cognitive load, higher developer productivity and better maintainability.

In my experience, writing business logic in SQL results in fewer bugs and less code. I have replaced 50-line Java methods with 15-line SQL projections multiple times. With Python, the ratio is closer to 2:1, but it's still impressive.

And all of this without having to consider type impedance, eager versus lazy loading, result set mappings, second-level caching, dirty tracking, lifecycle management, OCC, or obscure savepoint bugs. Performance is just a nice, but welcome side effect.

[1] https://www.youtube.com/watch?v=SxdOUGdseq4

Re: Django: One ORM to rule all databases

#82
post #79
post #48

Earlier quoted context omitted.

> and can write difficult queries by hand So now I have to learn an ORM (with some kind of lifecycles, dirty tracking, eager/lazy loading config, etc.)... aaaaand I have to learn SQL as well, because the ORM's abstraction is leaky. I see some benefits in ORMs for deleting and updating tables. But the benefits are slim and the cost (learning a library that requires understanding of quite a list of additional concepts)…

For many people, it's a gateway to back-end development. You don't have to learn all those weird, ancient tools, you just write a bit of Python. Look at this simple example! And then they get stuck on it.

Exactly. Then you learn SQL when needing complexer queries or more performance.

The result:

https://www.reddit.com/r/Entrepreneur/s/SMqhSBxje7

Re: Django: One ORM to rule all databases

#83
post #82
post #79

Earlier quoted context omitted.

For many people, it's a gateway to back-end development. You don't have to learn all those weird, ancient tools, you just write a bit of Python. Look at this simple example! And then they get stuck on it.

Exactly. Then you learn SQL when needing complexer queries or more performance. The result: https://www.reddit.com/r/Entrepreneur/s/SMqhSBxje7

No indexing ... I can definitely see how that happens.

Re: Django: One ORM to rule all databases

#84
post #78
post #75

Earlier quoted context omitted.

How? Stored procedures? I find that to be insane. How do you version that code, and how do you reason with the business logic split all over the DB and code?

> How? Stored procedures? Not neccesarily. jOOQ[1] and sqlc[2] are great options if you don't like stored procedures, but for a small app or a prototype, just having plain SQL strings in your app is fine. My point isn't that the code has to be stored in the database, but rather that the processing happens in one place where your data is stored and your middle tier just gets the results. Pure, stateless data. This mea…

jOOQ is also a great option if you do like stored procedures

Re: Django: One ORM to rule all databases

#85
post #81
post #80

Earlier quoted context omitted.

I don’t get this at all, and I tried to understand it. I'm good at SQL. When necessary (maybe once a year), I can drop into pure SQL instead of Django ORM like it's nothing. The thing is, I can't imagine why I would ever want to. All these anti ORM comments read like they want to be as close to the DB as possible. This is not what I want. I don't care about guaranteeing the most efficient query, because it is never t…

Again, performance is not my point. If you want maximum performance, use a low-level key-value store, hence my VSAM analogy. On the contrary, for me it is about simplicity. SQL is the most high level language in common use. It abstracts away everything: Storage, memory, concurrency, and, most importantly, control flow. Complexity comes from complecting things, simplicity comes from decomplecting [1] things. SQL decom…

The results would be opposite for me.

I need dynamic query building in most places.

Doing those inline in SQL would result in a mess of unmaintainable manual string concatenation and parameter interpolation.

A code uglier does not exist.

Post reply on HN