Declarative, interrogative, and imperative sentences in computer languages

The following English sentences have different forms (syntax):

  • Declarative: You are my friend.
  • Interrogative: Are you my friend?
  • Imperative: Be my friend!
  • Exclamative: What a good friend you are!

They also have different meanings (semantics):

  • Statement: You are my friend.
  • Question: Are you my friend?
  • Command: Be my friend!
  • Exclamation: What a good friend you are!

The form and meaning of a sentence usually match, but not always, as professor of English linguistics Bas Aarts explained:

Incidentally, you might be interested to know that sometimes we have a mismatch between the structure of a sentence, and how it is used. If I say to you at dinner Can you pass me the salt? then this is technically a question that has ‘yes’ or ‘no’ as possible answers, but in fact the pattern is used here to tell you to do something. It’s because of these possible mismatches that linguists prefer to use two sets of terms to describe the phenomena above. For the sentence patterns they use declarative, interrogative, imperative and exclamative. Corresponding to this are statement, question, command and exclamation to describe how these patterns are used.

The grammars of human languages such as English are flexible enough to allow the four forms of sentences (declarative, interrogative, imperative, and exclamative). I wonder if this also holds true for computer languages such as Python, HTTP, SQL, HTML, and CSS. They do not seem to allow exclamative sentences.

Are the following sentences declarative?

  • Python: assert x == 3
  • HTML: <!DOCTYPE html><html lang=""><title>x</title>
  • CSS: h1 { font-size: 3rem; }

Are the following sentences interrogative?

  • Python: x == 3
  • HTTP: GET / HTTP/1.1rnHost: domain.org
  • SQL: SELECT x FROM relation;

Are the following sentences imperative?

  • Python: x = 3
  • HTTP: PUT / HTTP/1.1rnHost: domain.orgrnrn{"x": 3}
  • SQL: INSERT INTO relation (x) VALUES (3);

If that is so, Python is the most flexible computer language (declarative, interrogative, and imperative), followed by HTTP and SQL (interrogative and imperative), and HTML and CSS are the least flexible (only declarative).