Sylwia Vargas
Posted on • Updated on
#sql #watercooler #computerscience #todayilearned
Welcome to my little CS trivia series. Every week I post a new trivia piece.
Today's question is...
Why is SQL shouting at me?
In the times of online communicators, emails and texts, many people find SQL syntax a bit too aggressive.
Why is SQL not obeying the rules of netiquette? There are a few reasons.
Historical context
SQL was created in 1974 when apparently majority of the keyboards did not have lowercase letters. Moreover, there were only six bits available to play with in character encoding, which is why languages like COBOL or FORTRAN also user uppercase. This was also the case with HTML (created in 1991), which initially had tags written in all caps until 2014 when the standards and syntax were changed.
Syntax Highlighting
This a bit aggressive syntax was kept for the purpose of syntax highlighting. Back in the days, there were no fancy linters and so keywords weren't highlighted in any way when you wrote code. The SQL capitalization provides a quick and easy way to visually break up the different parts of the query, helping people differentiate between the SQL parts and the database objects parts of the queries. Joe Celko writes about it in SQL Programming Style:
Rule: Uppercase the Reserved Words.
Rationale:
Uppercase words are seen as a unit, rather than being read as a series of syllables or letters. The eye is drawn to them, and they act to announce a statement or clause. That is why headlines and warning signs work.
Typographers use the term bouma for the shape of a word. The term appears in paul Saenger's book (1975). Imagine each letter on a rectangular card that just fits it, so that you see the ascenders, descenders, and baseline letters as various "Lego blocks" that are snapped together to make a word.
The bouma of an uppercase word is always a simple, dense rectangle, and it is easy to pick out of a field of lowercase words.
Keywords avalanche
Important to add, SQL has a large number of keywords and relies on the reader's ability to distinguish keywords versus identifiers in order to mentally parse the syntax. How does this relate to the capitalization?
Research has proven ALL CAPS is harder to read, so much so that the USA Federal Highway Administration has mandated the use of mixed-case signs in their Manual on Uniform Traffic Control Devices(2003), which states:
The lettering for names of places, streets, and highways on conventional road guide signs shall be a combination of lowercase letters with initial uppercase letters.
The New York Post also adds:
Studies have shown that it is harder to read all-caps signs, and those extra milliseconds spent staring away from the road have been shown to increase the likelihood of accidents, particularly among older drivers.
I personally like angry-typing SQL when I'm frustrated with e.g. prolonged quarantine. While at it, check out this amazing SQL exercise series by zchtodd!
Top comments (8)
Subscribe
Zohar Peled
Zohar Peled
By day, try to work.By night, try to sleep.
-
Location
Israel
-
Work
.Net Developer
-
Joined
• Mar 24 '20
IMHO, even with syntax highlighting, the separation of upper case for keywords and lowercase for anything else still helps readability.
It was an interesting read (Though I did suspect that was the reason, just not with all the details).
Sylwia Vargas
Sylwia Vargas
I'm a tech writer and educator advocating for code newbies ✨ I'm also a Developer Relations Lead + front-end dev at @inngest
-
Location
New York
-
Pronouns
she/her
-
Joined
• Mar 26 '20
- Copy link
Thank you! I do agree about the readability of SQL. Though, if I come back to it after some break, I again have an impression that it's a language for angry folks :D
Yechiel Kalmenson
Yechiel Kalmenson
He/Him/HisI'm a Software Engineer and a teacher.There's no feeling quite like the one you get when you watch someone's eyes light up learning something they didn't know.
-
Email
-
Location
NYC
-
Education
Flatiron School
-
Work
Software Engineer at VMware
-
Joined
• Mar 23 '20
- Copy link
LOL never thought of that! :D
Sylwia Vargas
Sylwia Vargas
I'm a tech writer and educator advocating for code newbies ✨ I'm also a Developer Relations Lead + front-end dev at @inngest
-
Location
New York
-
Pronouns
she/her
-
Joined
• Mar 23 '20
- Copy link
I know, you always assume the best intentions ❤️ I'm sure you thought that SQL is just being REALLY EXCITED!
Yechiel Kalmenson
Yechiel Kalmenson
He/Him/HisI'm a Software Engineer and a teacher.There's no feeling quite like the one you get when you watch someone's eyes light up learning something they didn't know.
-
Email
-
Location
NYC
-
Education
Flatiron School
-
Work
Software Engineer at VMware
-
Joined
• Mar 23 '20
- Copy link
SELECT * FROM table!!! SELECT IT ALREADY!!!!!!!!
leob
leob
-
Joined
• Mar 24 '20 • Edited on Mar 24 • Edited
- Copy link
I definitely prefer coding my SQL (or should I say "sql") in LOWERCASE :-)
Abhishek
Abhishek
Working on "AI on Steroids"
-
Location
New York
-
Work
Relevant at Meself
-
Joined
• Mar 24 '20
- Copy link
Maybe it's just really excited!
Sylwia Vargas
Sylwia Vargas
I'm a tech writer and educator advocating for code newbies ✨ I'm also a Developer Relations Lead + front-end dev at @inngest
-
Location
New York
-
Pronouns
she/her
-
Joined
• Mar 26 '20
- Copy link
It must be that joy that SQL cannot just contain :D
For further actions, you may consider blocking this person and/or reporting abuse