Hacker News new | ask | show | jobs
by pilif 4423 days ago
I'm probably totally old-fashioned and crazy, but I personally think the SQL code is much more readable and understandable than the arel code that's generated.

Why does everybody hate SQL so much that they have to invent their own query language which will eventually evolve to have the same capabilities as SQL but which will look differently, and will be specific to a host language?

Sure. There's the issue of SQL injections, but libraries have gotten good enough for these not to happen any more, to the point that writing straight SQL only has advantages: It works in any host language/framework, everybody understands it even if they are new to a language/framework and everybody can use the same language in their database GUI that they use while programming.

3 comments

"Sure. There's the issue of SQL injections, but libraries have gotten good enough for these not to happen any more"

Yes. And in this case, the "library" is Arel...

Well, I don't think these embedded SQLish languages are created because they're better than SQL. It's because working with strings is problematic, especially if you want to dynamically build up queries. Having a data structure that represents your query makes it much easier to safely and sanely compose various bits of query to build a new query at runtime.
Working with strings as code causes editors to get confused, is hard to compose, and means you lose out on any kind of static analysis.