Punctuate your sentences like you would computer code; your syntax will thank you.

By Joshua Yearsley (@joshuayearsley)

Although punctuation and syntax are generally considered separate topics–grammar, punctuation, and syntax form the typical trifecta–they interlink in subtle yet important ways. Let’s think about how punctuation and syntax act together through the lens of programming.


When I was a kid, I wanted to be a computer programmer just like my dad. That wasn’t to be, but I still carry some lessons from those days with me as I edit today. Syntax and punctuation are tightly linked parts of language—probably nowhere more than in programming, where one misplaced or incorrect symbol can break everything. To alleviate confusion, mathematics and programming tightly regulate the meaning and use of each symbol ($, #, {, !, etc.). For example, parentheses, brackets, and curly braces are used in math to denote different nested levels:


In English, the rules for using symbols (punctuation) to nest and separate words are a bit looser, making it easier to write correctly but sometimes harder to understand. While you’ll rarely see this many levels of nesting unless you’re reading David Foster Wallace, more common are stand-alone separators inside of nested phrases—the area on which we’ll focus today. Consider this kinda-awkward sentence:

Those who threatened his lands, whether refugees, scavengers, bandits, or rivals, soon faced armies of dead.

Nothing is technically wrong, but it’s a little difficult to parse. It makes sense after a second read, but we don’t want that second read; that second read needs to go. The problem here is that commas denote the nesting punctuation as well as the internal punctuation. Let’s break the sentence down, stripping it down to the bare bones and inserting some computer-code-looking symbols (| means “or”):

Those { refugees | scavengers | bandits | rivals } faced armies.

Refugees, scavengers, bandits, and rivals encompass the appositives for “those”. For the sentence to read easily, we need to cue the beginning and ending of “whether refugees, scavengers, bandits, or rivals”,  the appositive phrase. How do we accomplish this? Just change the punctuation!

Those who threatened his lands—whether refugees, scavengers, bandits, or rivals—soon faced armies of dead. Problem solved.

Nuanced Nesting

You can go crazy with nesting, but certain punctuation marks are clearer or more appropriate than others depending on the situation. Some cannot be used as nesting punctuation at all (semicolons), while others can only be used in that way (parentheses).

As a rule of thumb, use an exotic punctuation mark (em dash or parentheses, depending on how much emphasis you want to place on the parenthetical phrase) as the nesting punctuation and a common mark (usually a comma, sometimes a semicolon) as the interior separator. You can use em dashes on the inside to set off text that you’d like to emphasize, but tread with care—there be dragons. I’ll close with some examples, from simple to needlessly complex:


I went to the store (boy, do I hate driving in traffic) to pick up a gallon of milk.

Em-Dash Parenthetical

I went to the store—although it was cold outside, and boy do I hate driving in traffic—to pick up a gallon of milk.

Compound Parenthetical

I went to the store (I hate driving in traffic; it sucks, and I don’t like it) to pick up a gallon of milk.

Em-Dash-Interior Parenthetical

I went to the store, the store which—to my surprise—appeared before my eyes, and picked up some milk.

Em-Dash Parenthetical with Super-Comma Semicolons

I went to the store—picking up a gallon of milk, a donut, my favorite pastry; a loaf of bread, whole wheat; and a six-pack for the after-party, of course—and then drove home.

Flickr image by Sebastian Fuss, CC BY-SA 2.0