:blobwizard: Tsatnosk is a user on manowar.social. You can follow them or interact with them if you have an account anywhere in the fediverse.
:blobwizard: Tsatnosk @zatnosk
Why is it that SQL's keywords are conventionally written in capital letters? I've been doing it for years without questioning it, even though I know at least MySQL doesn't care either way.
ยท 0 ยท 0

@zatnosk A low tech form of syntax high lightning, I guess.

SQL is often embedded in literal strings in other languages (and often just in fragments), so it is harder for the editor to detect that some code should be high lighted as SQL.

@pmakholm@mastodon.technology If you're making complete SQL statements in a string, they're pretty easy to detect; they all start with one of a relatively small list of keywords; "select", "update", "delete", etc. No need for capitalizing those keywords to recognize them.

@zatnosk No, but still harder than "Hey, this is a literal string โ€“ Let me just skip to the end" (And even that can be tricky)

@pmakholm@mastodon.technology True that, but that's a problem with any string-embedded DSL. Do other embedded languages use capitalized keywords?

@zatnosk I can't think of other string embedded DSLs as ubiquitous as SQL

(with the possible exception of PCRE's)

@zatnosk None of the SQL engines I've used care (DB2, Postgres, SQLite, MS SQL)

I think it's to help tease apart keywords from the actual stuff you care about.

SQL is very close to natural language and it's a trick to keep the language separate from the logic.

At least that's why I find it useful ๐Ÿ˜€