Live data from Hacker News

What ORMs have taught me: just learn SQL (2014)

woz.posthaven.com

131–140 of 360 posts

Re: What ORMs have taught me: just learn SQL (2014)

#131
post #121

Earlier quoted context omitted.

One problem with having logic in the DB is that it's much harder to scale if you need 10x more computing power.

Moving the definition of your sql from your app to the database doesn't impact scalability, as in both cases the database needs to perform the query.

We're talking about stored procedures, which are executable code/business logic.

Re: What ORMs have taught me: just learn SQL (2014)

#132
This type article of article has come up countless times before. Why not both? Using both, you let the ORM handle regular, boring CRUD, validation, repeatable exercises, and write tricky joins, aggregates, function calls that ORMs don't do well in SQL. Every decent ORM supports dropping to SQL.

Re: What ORMs have taught me: just learn SQL (2014)

#133
post #14

I think saying "Just use SQL" is probably a bad idea. You'll most likely end up implementing an ORM anyway, or you will end up with your model code mixed up everywhere with your views. I do think a lot of people use ORMs as a crutch, which sucks. Also, ORMs often provide too much abstraction, forcing people who actually know SQL to relearn how to do everything the way the ORM happens to like it. I should not have to…

No. You should really wind up with a DAL. Define some stored procedures for accessing and working on the data and use only stored procedures.

No need for ORM, and no inline sql logic in your application code.

Re: What ORMs have taught me: just learn SQL (2014)

#134
Disagree on joins and foreign keys: normalized tables make for smaller tables in my experience. Sure you might denomalize for reporting but it’s best to normalize and then demoralize as needed not avoid foreign keys because you have to write a large number of joins

Re: What ORMs have taught me: just learn SQL (2014)

#135

The first time I've seen an ORM I was fascinated by this seemingly beautiful idea. But I have quickly realized that it's almost useless in real life projects, plain old SQL seems just much much better. Now I don't understand why would anybody use an ORM actually. Also, basic SQL can be easily taught in as little as 10 minutes (I have been initially taught it at middle school during MS Office Query, Access and VBA cla…

> But I have quickly realized that it's almost useless in real life projects

there are plenty of real life projects out there that would beg to differ

Re: What ORMs have taught me: just learn SQL (2014)

#136

Some people, when faced with a database problem, choose to use an ORM on top of an RDBMS. Those people now have three problems. The problems are: the original problem, the expressive and performance disaster that is every ORM ever, and the layered and hidden RDBMS whose peculiarities nonetheless always find a way to leak through the ORM abstraction. Fun stuff. Do what TFA says: just learn SQL.

I've been using Django + Django ORM for a decade, and it has covered vast majority of database usage. Entire applications written with zero SQL, and clean DRY code describing data and allowing to use it in the code. And yet other application written with lots of SQL.

The real question is, why anyone using an ORM not learning SQL, how the the thing they are mapping to objects actually works?

Re: What ORMs have taught me: just learn SQL (2014)

#137
post #13

Why are we even having this debate? There are some ORMs that bring so much value to the table that you'd be stupid not to use them. Example being Django's ORM or SqlAlchemy. Also be specific in what ORM you are comparing to raw SQL. Are you talking about Hibernate or SQLAlchemy. Are you talking about a query builder? Good ORMs help tremendously with maintainability and security. They also let you drop down to raw SQL…

I disagree. ORMs dont bring value, they dilute value and piles abstractions upon apstractions. Your application becomes hard to maintain, database hard to refactor, queries slow.

ORMs seems nice for simplified problems but becomes a horrible mess for real problems imho...

I've worked on some rails apps, and the ORMs caused more problems than they solved...

Re: What ORMs have taught me: just learn SQL (2014)

#138
post #43

> If you're using an RDBMS, bite the bullet and learn SQL. If this person spent all that time using Hibernate and then SQLAlchemy, and all that time did not know SQL, then their suffering and bad experiences make complete sense. You absolutely need to know SQL if you're going to use an ORM effectively. Good ORMs are there to automate the repetitive tasks of composing largely boilerplate DML statements, facilitating q…

He wrote:

"Attribute creep and excessive use of foreign keys shows me is that in order to use ORMs effectively, you still need to know SQL. My contention with ORMs is that, if you need to know SQL, just use SQL since it prevents the need to know how non-SQL gets translated to SQL."

Re: What ORMs have taught me: just learn SQL (2014)

#139
post #43

> If you're using an RDBMS, bite the bullet and learn SQL. If this person spent all that time using Hibernate and then SQLAlchemy, and all that time did not know SQL, then their suffering and bad experiences make complete sense. You absolutely need to know SQL if you're going to use an ORM effectively. Good ORMs are there to automate the repetitive tasks of composing largely boilerplate DML statements, facilitating q…

> providing abstraction for database-specific and driver-specific quirks

That is quite theoretical. My PRs for fixing non-spec compliant behavior in pgjdbc get rejected because they might break some ORMs (mostly Play). My PRs for adding MariaDB sequence support to Hibernate get rejected because there are additional MariaDB features that Hibernate doesn't support as well.

Re: What ORMs have taught me: just learn SQL (2014)

#140
If you are working with Node.js and Postgresql, give tabel(https://github.com/fractaltech/tabel) ORM a shot. It is an unconventional ORM that works with pure JS objects and arrays, instead of "Model" classes, and "Collection" classes, and what not. It has quite a few other nifty features too.
Post reply on HN