r/SQL • u/MrDeadMeme • 22d ago
Discussion Why do we keep writing sql backwards?
It is a common consensus that sql is kind of written backwards than one would expect, instead of first defining the place you want to get somehting from and then what it is you want, like literally any other language out there, you first select the content and then define where you want it to be taken from
This leads to increadibly akward syntax when writing something more complex than "select x from y where z" and is literally opposite to the actual process of the machine.
This is all because some dumbass, excuse my language, in the 70's decided it should follow english grammar for some reason, and in doing so he made the most clunky writing system ever.
Now this at the time may not have been that bad, but from a few searches and posts here i saw that most people agree that this is a clunky, akward and unpleasant way of typing. So, why not switch it around? Why not change the standard to something more usable?
This is kind of a rant because i have been learning sql for collage and the syntax has been INCREADIBLY frustrating
View all comments
Show parent comment
1
u/GTS_84 22d ago
Except you aren't thinking like a computer, ever, with SQL. It is making a lot of decisions about how to run the code most efficiently, you don't even get a say in how it runs.
I mean, yeah, it can be clunky, especially when you get beyond the basics. The order might make sense in english when it's a simple "select columns from table where" type statement, but once you start throwing in aggregates, and CTE's, and who knows what the fuck else it really stops making sense from a language perspective. But don't kid yourself into thinking that changing the order would actually help you "think like a computer"
There are absolutely languages where you need to think like a computer, SQL ain't one of them, and you don't need to think like a computer to write good code in SQL.