News for hackers. Stuff that matters.
Re:Things I wished more developers knew about databases by pjc50 on Wednesday April 22, 2020 @11:20AM (#22946481)
This is partly why I love LINQ: it's a more C# flavoured way of expressing queries. And it works on objects as well as databases.

Most ORMs are bad for queries (pull over all the objects and look at their properties!), but LINQ will actually turn your code into SQL under the hood with some remarkable machinery.

Re:Things I wished more developers knew about databases by fernandotakai on Wednesday April 22, 2020 @12:35PM (#22947397)
>Most ORMs are bad for queries (pull over all the objects and look at their properties!)

i would change that to ORMs CAN be bad for queries. most ORMs are super configurable and can be changed only to pull specific stuff.

i would argue that most ORMs are a plus to productivity because for most of cases, you just need simple querying (select * from, simple updates, simple deletes).

also, if you really need the power of raw sql you an just use that -- and even then, for most advanced ORMs (django's, for example) exposes a LOT of really advanced sql stuff in python, which, for a lot of developers, is a lot more expressive.

Re:Things I wished more developers knew about databases by uhoh-itsmaciek on Wednesday April 22, 2020 @12:07PM (#22947062)
Which ORMs are bad for queries? Most popular ORMs these days expose most of sql in a language-specific DSL (and some allow you to splice in bits of raw sql in a semi-structured way as an escape hatch). Sure, you still need to learn to "think in sql", to use these effectively, but the ORM has not been the problem for a long time in most languages.
Re:Things I wished more developers knew about databases by ratww on Wednesday April 22, 2020 @01:28PM (#22948019)
ActiveRecord, Rails ORM was the poster child of ORMs for a while, and is completely abysmal for non-trivial left joins, non-trivial aggregations and some subqueries.

Of course using raw SQL is possible but might force you into converting other parts of the code into raw SQL. There is Arel, but it's just a more verbose SQL in quasi-AST form.

On the other hand, I never had much problems with LINQ or Hibernate.

Re:Things I wished more developers knew about databases by andybak on Wednesday April 22, 2020 @11:23AM (#22946514)
Not doubting there are bad ORMs but none of the ones I've dived into is quite that bad (SQL Alchemy and Django's ORM).

I sometimes wonder if the debate about ORM is mainly driven by some traumatic horror witnessed at some point in every developer's career. If we judged programming languages by the same metric... Oh... Actually we kind often do that too!