|
|
От: | Sinix | |
| Дата: | 10.12.15 13:31 | ||
| Оценка: | 70 (1) | ||
... SQL query editors don’t have a crystal ball that can predict what table or view you’re querying when you write:
SELECT Na
How is it supposed to autocomplete what you’re writing when it hasn’t seen the FROM clause (here spelled all caps because we’re talking about SQL) just yet? Moreover, it doesn’t make sense to write SELECT first because it’s the last thing that happens: Tell the source, filter items, sort them, and so on. But projecting the result happens at the very end. So why does it come syntactically first? I don’t know. If there’s a SQL language designer reading this book, send me an email and enlighten me!
DON’T REPEAT MISTAKES
Assuming the SQL order of operations was a mistake (it is), it would be silly to repeat it in today’s language design even if it were for consistency and familiarity with the SQL language people may already know.
In fact, Visual Basic 9.0 was in this camp for a long while, going to great lengths to keep the Select clause (here using typical Visual Basic spelling of the keyword) in front, with intractable and confusing code editor jumps while typing a query.
It went roughly like this, if I recall correctly:
Type Select and press space; a From clause would be inserted below what you already typed.
The editor jumps to the From clause where you specify the source and range identifier.
When you’re done with the From clause, as observed by the code editor upon pressing a space or Tab, you would go back to Select.
Back in the Select clause, you can now use the range identifier introduced in the second step.
This was highly unintuitive, and the Visual Basic team eventually surrendered and made the From clause come first. The fear people would dislike it because of its difference from the already familiar SQL language has, as far as I know, never really materialized.
So, even if some SQL language designers would defend their design choices, the .NET developer audience has shown that having the From clause first is much more intuitive in the end.