Write clearer code by putting it in order

Daniel Sockwell — 45 minutes

When writing prose, order matters. Or: Order matters when writing prose.

Order matters at the paragraph and section level – putting one's ideas in logical order is key to clear writing. But it also matters at the sentence level: good writers carefully consider the order of words in each sentence. They might select a particular order for many reasons, including emphasizing phrases by putting them first (or last), keeping verbs near their subjects, and grouping related phrases.

Programmers should be like good writers and order our code deliberately. Many of us pay a lot of attention to order at the "section level" of modules and at the "paragraph level" of functions and code blocks. But all too often we neglect code's "sentence level" – we don't put much thought into how to order terms within individual expressions. Sometimes that's because the programming language forces a certain order on our code; other times, it's due to habit or inertia.

In this talk, we'll consider the approaches different programming languages take towards order at the expression level. Next, we'll turn to Raku and examine the (sometimes-underappreciated) tools Raku provides for putting our code in order – tools powerful enough to give us near-total control over our code's order. Using these tools, we'll write and rewrite Raku expressions in different orders; we'll consider what each order communicates or emphasizes. And then we'll turn to the other side of the equation: how to write our own functions and objects so that anyone using our code can select the order that best communicates *their* intent.

This presentation aims to be the start of a conversation, not the end of one. So we'll have ample time for questions, comments, and opposing views.



Talk tags
expressive code, clarity, programming paradigms, language design, API design, linguistics
Target audience
Any
Talk duration
45 minutes
Talk status
accepted