Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

OOP is not simplifying CRUD or DB ops because you want to batch.

You don’t want lazy loading. You don’t want to load 1 thing. You don’t want to update 1 thing.

You want to actually exploit RETURNING and not have the transaction fail on a single element in batch.

If you care about performance you do not want ORM at all. You want to load the response buffer and not hydrate objects.

If you ignore ORM you will realize CRUD is easy. You could even batch the actual HTTP requests instead of processing them 1 by 1. Try to do that with a bunch of objects.

I would personally never use ORM or dependency injection (toposort+annotations). Both approaches in my opinion do not solve hard problems and in most cases you don’t even want to have the problems they solve.



I agree with you, but I am not sold on optimizing for performance above all else.

Business logic ran fine on ancient mainframes. It can run fine on Raspberry Pis.

CRUD is super easy. It's also not super resource intensive.

I know that's the path that led us all down into Java OOP / start menu is a react native component, but it is actually true.

ORM adds a convenience layer. It also adds some decent protection against SQL injects OOTB and other dev comforts.

Is that trade off worth it? Probably not. But sometimes it's the best tool for the job


Optimize for your users above all else. Yes, even above developer experience. If that means optimize for performance, you optimize for performance.

The only thing that matters is what your users feel when using your product. Everything else is a waste of time. OOP, FP, language choice, it's all just fluff.


I think this is a wonderful philosophy, but many times the actually more important thing is "optimize for the client's budget"


Sometimes the client just can't afford your services. There is nothing wrong with that. :)


ORM gives:

1. migration

2. Validation when inserting

3. Validation when loading

3.1. Serialization

4. Joins

5. Abstracts away db fully if you want, not use db specific features

6. Lazy loading as an encapsulation promoting mechanism

None of these things are especially hard and I’d argue query builders that compose and some other tools deal with these points in a simpler and more efficient manner. Migrations in most cases require careful consideration with multiple steps. Simple cases are simple without ORM.

I’m pretty confident most users of ORM are dealing with problems inflicted by ORM behavior, not db. The biggest infliction is natural push towards single-entity logic that is prevalent in OOP and ORM design.


Are you suggesting that you can't update more than 1 thing at a time in a transaction with any ORM?


No.

You can go further and ask me if I imply lazy loading is mandatory.

Imagine what happens when lazy loading turns off. You lose encapsulation. How will OOP work now if you have to reason about your whole call stack and know what exactly has to load up front?

Why can lazy loading be turned off? What if I write my code BAU and then realize I need to turn it off?


Sorry, there must be a language barrier. Good luck.


If you want to participate, paste this into a LLM and ask it questions. Might be a barrier that has nothing to do with language.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: