News for hackers. Stuff that matters.
Re:Ask HN: Raw SQL vs. ORM? by acutesoftware on Wednesday April 11, 2018 @07:04AM (#16809841)
Yes, if you already know SQL and by using bind-parameters, then I [personally] can't see a tangible benefit for using an ORM.

They can certainly make for cleaner looking code, and are useful for people who don't really understand the database schema, but not worth the added complexity.

Re:Ask HN: Raw SQL vs. ORM? by timrichard on Wednesday April 11, 2018 @07:12AM (#16809894)
Just to mention another alternative, I've been using a QueryBuilder library on the last two projects. The code's prettier than it would be with raw SQL, plus there aren't ORM downsides.
Re:Ask HN: Raw SQL vs. ORM? by pserwylo on Wednesday April 11, 2018 @07:20AM (#16809969)
Good point. We had great success doing this with our PHP code base. For us it wasn't about pretty or not-pretty code, but rather about type safety. The idea that you can have a method which accepts "WhereClause $constraints" instead of "string $constraints" means you can be much more confident that the code is correct.

We actually wrote a custom query builder because none of the available ones (e.g. Doctrine) had the type safety that we desired. A direct parallel to what we used is the Java library JOOQ, in terms of its querybuilder API [0].

[0] https://www.jooq.org/doc/3.10/manual/sql-building/sql-statem...

Re:Ask HN: Raw SQL vs. ORM? by Allstar on Wednesday April 11, 2018 @07:26AM (#16810024)
Same here, we use Knex.js Querybuilder to build queries and fallback to `knex.raw()` for very specific SQL queries.
Re:Ask HN: Raw SQL vs. ORM? by timrichard on Wednesday April 11, 2018 @07:56AM (#16810201)
Ah, coincidence... Knex is the one I've been using too :-)