Live data from Hacker News

What ORMs have taught me: just learn SQL

wozniak.ca

21–25 of 25 posts

Re: What ORMs have taught me: just learn SQL

#21
post #7

Earlier quoted context omitted.

You know what works really well regardless of database? Regular boring old Ansii SQL without vendor-specific addins.

Sure, but you'd still need to connect and interface with the SQL implementations - the queries themselves are the smaller piece of the work if you want to support several different database backends.

> the queries themselves are the smaller piece of the work if you want to support several different database backends.

Not if you use something like the Delphi / Lazarus model with pluggable drivers and direct SQL capability (and stick to whichever variant of ANSI-standard SQL your intended backends have in common).

Re: What ORMs have taught me: just learn SQL

#22
post #13

This post should be titled "what ORMs have taught me: world is black and white, if you use ORM, you can't use SQL". Are ORMs leaky abstraction? Yes. All non-trivial abstractions are leaky. Can you write 95% of code in ORM and drop to raw SQL for 5%? Yes.

>All non-trivial abstractions, to some degree, are leaky. https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-a...

From your link, a remarkable irony:

>The SQL language is meant to abstract away the procedural steps that are needed to query a database

Leaky abstractions, all the way down?

Re: What ORMs have taught me: just learn SQL

#23

Earlier quoted context omitted.

>All non-trivial abstractions, to some degree, are leaky. https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-a...

From your link, a remarkable irony: >The SQL language is meant to abstract away the procedural steps that are needed to query a database Leaky abstractions, all the way down?

I would definitely say SQL is leaky. Certainly not fully declarative. I think it’s important to have escape hatches though - if you have to be leaky you may as well be intentional about it.

Re: What ORMs have taught me: just learn SQL

#24
post #12
post #6

A number of specialists in the field of databases got together and designed a DSL specifically for working with databases. It's actually a pretty good fit for its domain and is reasonably well designed. It's also pretty simple (it's even right in the name). Then a bunch of non-specialists said "we don't want to use more than one language" and came up with some hacks to write DB queries in languages that were never de…

With an ORM you can leverage the IDE to get field names, types and descriptions by simply typing out the name of the model. In pure SQL you need to memorise the schema, or continuously switch contexts to refer back to it. Another advantage is that you type-check your queries, whereas with pure SQL you can accidentally load a number into a string variable and crash the application. Because of this I prefer very light…

I guess it's all the standard trouble with DSLs: poor tooling integration, having to work at different layers.

An IDE that understood SQL would probably mitigate almost all opposition and yet nobody came up with one after all these years. So I guess the standard DSL defense doesn't really doesn't work.

All right, point taken, I'll take my downvotes and go home :) I don't use an IDE and most people I work with don't either. But this is a useful reminder that the world can be very different outside of one's bubble.

Re: What ORMs have taught me: just learn SQL

#25
post #6

A number of specialists in the field of databases got together and designed a DSL specifically for working with databases. It's actually a pretty good fit for its domain and is reasonably well designed. It's also pretty simple (it's even right in the name). Then a bunch of non-specialists said "we don't want to use more than one language" and came up with some hacks to write DB queries in languages that were never de…

I know quite a few languages, frameworks, what have you and if you can't see the benefits of not adding another damn thing for people to learn on to the pile, then I have no idea how you've missed a lesson that up to this point, it seemed every engineer I'd met has learned. Not having to specify the mapping between business objects and a SQL database is massive value on it's own. Having not only the ability to avoid…

I guess we have met different subsets of engineers :)

I wish people were more open to learning more languages. A good DSL can be amazingly expressive. But you are correct in pointing out that gluing languages together is a pain, and it's a good reminder. Lesson learned ;)

Post reply on HN