by nzmsv · 5y ago · 0 comments
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 designed for that. The hacky stuff actually ends up generating the proper query language behind the scenes, poorly.
One would wonder why would anyone prefer the hacks, but the appeal of using one language for everything is strong. This is also why DSLs never took off in general despite promising to significantly lower the cognitive load due to being a better fit for the problem domain. At least with most DSLs there are usually additional reasons not to use them: the implementation is usually not as good as the popular languages. This is not true for SQL, and yet is suffers from the same problem.
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 doing that, but upon making changes to your objects, being able to migrate the database easily is frankly amazing.
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 ;)
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 ORMs that abstract almost nothing. Those that provide model definitions, automatic migrations and a one-one SQL mapping.
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.
Any particular recommendations? I tried hibernate in java and was put off by complexity.