Webster’s Dictionary defines a compound sentence as “a sentence consisting of two or more independent, coordinate clauses (Ex.: She drinks coffee, but he prefers tea.)” A clause is a group of words that contain, at minimum, a subject and a verb: He eats. We play. The dog sleeps.
The standard grammatical rule is that compound sentences should be separated by a semicolon or by the combination of a comma and a conjunction (e.g., and, but, or). However, The Chicago Manual of Style allows writers to omit the comma if no ambiguity will result. “She drinks coffee but he prefers tea” would just as easily suffice because the sentence is still clear.
Unfortunately, many writers assume clarity where it does not exist. Consider the following from Yuval Noah Harari’s Sapiens:
Poets composed paeans to its fierce defenders and painters committed majestic depictions of the siege to canvas.
The problem is that the sentence initially reads as “poets composed paeans to its fierce defenders and painters.” As such, the poets composed paeans for both the defenders and the painters, and the painters are fierce like the defenders. It is only when the reader continues on that painters becomes the subject of a second, independent clause. If a line break came after painters, the reader would certainly stumble (if they haven’t already). For clarity, the sentence should read:
Poets composed paeans to its fierce defenders, and painters committed majestic depictions of the siege to canvas.
Conversely, authors sometimes add a comma to what at first appears to be a compound sentence but is not. This also from Sapiens:
Cultural diversity and territorial flexibility give empires not only their unique characteristics, but also their central role in history.
“But also their central role in history” is not an independent clause: it’s missing a subject and verb. Consequently, the sentence should be written:
Cultural diversity and territorial flexibility give empires not only their unique characteristics but also their central role in history.
There are exceptions to every rule, of course, and a comma may be necessary in order to maintain clarity:
He recognized the woman who took the stage, and laughed.
Without the comma, it is the woman who laughed, not the man. But rather than rely on the comma, it might be better to rewrite:
The woman took the stage. He recognized her and laughed.
(Note: both options use the same number of words and characters, so the writer isn’t losing any brevity with the rewrite.)
The comma is also used when the subject and verb of a sentence is implied in a series of dependent phrases. For example:
You can take the 8:15 train from Liverpool Station, or the 8:20 bus from Liverpool Street, or a taxi.
In this example, or implies “or you can take,” and thus it is unnecessary to repeat the phrase.
When trying to decide whether to use a comma or not, look for missing subjects and verbs. Also read the sentence in parts, as if a line break might occur within the sentence. Is it still clear? If not, rework.