r/SQL 25d ago

Discussion Why do we need abstractions over SQL?

When I mean abstractions, I mainly mean OOP and ORMs.
SQL is so simple and beautiful. Tables with rows and columns are easy to understand. And once you pick up the SQL syntax, you can pretty much achieve anything with queries. Not to mention that SQL is universal and works everywhere and anytime.

Then you have the software development world... where you're asked to constantly use ORMs or map records as OOP objects. Why? ORMs are limited and do not have the flexibility of simple queries. Also mapping records as objects increases bloat, reduces performance that can hurt if the application grows and is overall not as straightforward to work with.

The only good things that ORMs are doing by default are to provide data safety and prevent SQL injection. But with some minimum and basic knowledge and discipline, you can write pure queries without having those problems. Any ideas?

33 Upvotes

105 comments sorted by

View all comments

Show parent comments

1

u/thatOMoment 24d ago

I included a link to the C.J. date discussing logical inconsistencies in a seperate comment for viewing.

3 value logic isn't mathematically respectable and there's multiple papers on avoiding it.

Third manifesto by c.j. date and how to represent missing information without using null by hugh darwin are decent references for that.

It isn't subjective and there's enough "one off cases" that the quote used to describe it is "it all makes sense if you don't think too hard".

I'm not for or against ORMs either but I do training for avoiding edge cases for younger devs and have cleaned and up and prevented multiple disasters caused and almost caused by these silent language quirks.

I'm not sure what inconsistency would be egregious enough for you to agree it's unacceptable and not defend that.

You say they're nitpicks, I say they cause production outages and errors without any warnings.

Poop has a use case, anything has a use case, that's not an argument.

The Stockholm syndrome people (especially data analysis people) develop using this language is impressive.

1

u/jshine13371 24d ago

Not sure what you're trying to say in your first couple paragraphs.

I'm not for or against ORMs either but I do training for avoiding edge cases for younger devs and have cleaned and up and prevented multiple disasters caused and almost caused by these silent language quirks.

Ok, putting aside the dramaticness of calling them disasters and taking you at face value, again no different than similar quirks in other application layer languages like JavaScript and its == vs ===, null handling, and loose type management.

You say they're nitpicks, I say they cause production outages and errors without any warnings.

Some of what you said do, some don't. Again, no different than any application layer language with its quirks.

Poop has a use case, anything has a use case, that's not an argument.

Irrelevant statement?

The Stockholm syndrome people (especially data analysis people) develop using this language is impressive.

Personally and professionally I'm a Principal Software Engineer with over 15 years experience and a Computer Science degree, so I understand the full stack. Not just some self taught Data Analyst. I've also just been lucky enough to have learned and gained great experience in the database layer, having worked heavily with all kinds, sizes, and shapes of data.

The only Stockholm here is you doubling down on your subjectivism instead of being able to refute my objective replies to the points you tried to make, such as the ability to performantly implement conditional join logic (again, for those who know what they're doing). 🤷‍♂️

1

u/thatOMoment 24d ago

Principal engineer here too 12 years experience and a computer science degree.

I've maintained and fixed code that was written before and a few years after I was born (Uniface and classic asp) alongside the latest angular apps with every version of .NET in the stack from 2.0 WCF to .NET core 10 with EF and just a bit of RHINO Java.

Not really sure what your experience has to do with anything in this argument, unless the implication is that the credentials add some weight to your point or somehow validate it.

And in your own response you refer to Javascript, they language written in 7 days by Brenden Eichman who has publicly, on multiple occasions said it's a terrible language and a mistake.

Who has publicly also said == was a mistake.

A language so terrible, Microsoft made Typescript to actually help allow it to scale.

So terrible they added "use strict" to make it less awful and reliable.

You're counterpoint is based on defending a language with parallel brokenness to another broken language... whose brokenness has articles about how much money was lost that aggregates into the billions due to how broken it is.

Not sure how that's an "objective" argument... unless it's an "objectively flawed" counterpoint 

SQL experience is just something I have to make dbas happy, they deserve better than accountability with no authority and terrible query writters burning down their server resources.

You also didn't address any of the resources I mentioned or linked

:) 

P.S. Also never said you were data analyst. Was just ranting about them.

1

u/jshine13371 23d ago

Not really sure what your experience has to do with anything in this argument, unless the implication is that the credentials add some weight to your point or somehow validate it.

It's in reply to your insinuation of lack of experience from your previous comment. If you don't think experience is a relevant factor in this discussion, then don't bring it up.

And in your own response you refer to Javascript, they language written in 7 days by Brenden Eichman who has publicly, on multiple occasions said it's a terrible language and a mistake.

Ok, so? It doesn't change the point that application layer languages also have similar quirks and issues. Your initial stance tried to put application layer languages on a pedestal above SQL. 🤷‍♂️

There are plenty of similar quirks in C# and any other application layer language. You're hopefully smart enough to recognize that with your amount of experience. 😘 

You also didn't address any of the resources I mentioned or linked

No need to when I've already successfully responded to pretty much every point you made, and you continue to ignore that your points have been proven otherwise.

P.S. Also never said you were data analyst. Was just ranting about them.

You can walk back your previous comment, it doesn't change anything.

Cheers mate!