Hacker News new | past | comments | ask | show | jobs | submit login

I've seen a litany of these kinds of posts and I'm always amazed by two things when I see them posted on HN:

1. A cadre of diehards can't wait to post how amazing Postgress is or would be for whatever it is the OP is doing (as an aside, why isn't Postgres more popular if it's so amazing?); and

2. How averse people are to actual SQL.

Years ago I dealt with this crap in the Java world back when Hibernate and the like were all the rage. I was always amazed at how much confirmation bias there seemed to be. People decided these ORMs were amazing and then completely ignored all the bugs introduced by this layer and effort spent trying to figure out what the ORM was doing and how to make it do the right thing.

Back in the day I always liked a Java data mapper framework called iBatis (now dead, replaced by Mybatis it seems), which was pretty simple. Write some SQL in an XML file and call that SQL from your Java code. It was parameterized (so no SQL injection issues) and you could still do some funky things with discriminated types and the like. Plus, analytics were super easy because you knew how often each query was called and how long it took. Also, you could easily EXPLAIN PLAN those queries if you even had to (usually needed indexes were obvious).

Compare this to the auto-generated SQL from the likes of Hibernate. ugh.

I've come to the conclusion that people have this tendency to decide X is bad and then go completely out of their way to avoid X. You see it with SQL and ORMs. It largely explains (IMHO) thing slike Javascript and GWT.

At least half the time "X is bad" really means "I don't understand X and I don't want to learn it".

Joel Spolsky's "leaky abstractions" is good and time-honoured advice.

Take the Hibernate example. Once you bought into that framework you had to do all your data access that way or you broke the caching. That's mostly bad.

People also overestimate their needs. They rush to create Hadoop clusters and distributed NoSQL solutions because, you know, relational DBs can't keep up with their "Big Data" (which means, millions of rows) when in fact you can dump billions of rows into a single MySQL instance.




To be blunt, I see a lot of irony in your post.

> People decided these ORMs were amazing and then completely > ignored all the bugs introduced by this layer and effort > spent trying to figure out what the ORM was doing and how > to make it do the right thing.

For every person that did this, I've run into at least one other that was convinced that ORMs were the most evil thing ever and that they should roll their own little Object Mapper. Every one of them would then completely ignore all the bugs introduced and effort spent trying to train new developers on their slightly unique thing and how to coerce it into doing the right thing.

"I've come to the conclusion that people have this tendency to decide X is bad and then go completely out of their way to avoid X. [...] Take the Hibernate example. Once you bought into that framework you had to do all your data access that way or you broke the caching."

There is nothing about Hibernate that requires you to fully buy into caching, or even to fully buy into its abstraction. In fact, I've generally avoided caching in Hibernate in order to retain the flexibility to do what I needed without it when I needed to.

Usually about 90% of the code ends up being really boring CRUD with trivial queries. The last 10% could be implemented with whatever crazy approach made sense.

And this isn't to knock those other frameworks either. iBatis and quite a few other early Java ORMs were quite good and arguably better than Hibernate was at the time, but Hibernate was marketed more effectively.


+1 for MyBatis. Good library that. If you're looking for something similar these days, JDBI [1] is great too.

[1] - http://jdbi.org/


> 1. A cadre of diehards can't wait to post how amazing Postgress is or would be for whatever it is the OP is doing (as an aside, why isn't Postgres more popular if it's so amazing?); and

I'm a happy MySQL user, all of my side projects and on the job work is done in MySQL. That said, how else would Postgres become more popular if there isn't some level of evangelism to spread the word? I like reading about Postgres features and maybe someday I will switch.

For now, with my/our needs, MySQL is fine


Wasn't aware of Mybatis, thanks :) With Clojure, I really like HugSQL for similar reasons (You're dealing with real SQL, rather than another fat layer(s) of abstraction).


Same here, rapid growing startup, Hibernate introduced many perfomance problems, replaced with JDBCTemplate which was much easier to reason about. Also Hibernate upgrades were a pain.

Also

http://codemonkeyism.com/beware-magical-code/ (2010)


I liked iBatis quite a bit too. Basically mapping hand bombed SQL to functions instead of objects (using XML ugh, but that was the norm at the time).

Hibernate was just horrible and I had to watch my entire team adopt it (EJB 1 era).




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

Search: