Fundamentals 8 min read

What Good Code Style Can Teach Us About Writing

The article explores how principles of clean code—clear naming, modular structure, and layered logic—can be applied to literary writing, using examples from classic Chinese novels to illustrate how thoughtful variable naming and multi‑threaded organization improve both code readability and narrative clarity.

21CTO
21CTO
21CTO
What Good Code Style Can Teach Us About Writing

I first encountered a programmer’s novel in 2009, which opened my eyes to a new species: the programmer. Later, reading Dream of the Red Chamber reminded me of a riddle that perfectly describes programmers.

After half a year of programming, the only thing I retained was the name Tan Hao‑qiang, but more importantly I learned the concept of “good code style,” a notion far more interesting than any textbook name and applicable across domains, even writing.

Variable naming, for instance, can make a title feel approachable. A literal title like “On Good Code Style” sounds stiff, while “How to Write Code with Good Style” feels pretentious. A casual phrasing such as “A Light Talk on Good Code Style” feels more friendly.

Good code style, like good writing, should avoid unnecessary complexity. Names should act as pointers: in Jin Yong’s novels, characters like Mu Nian‑ci and Bao Xi‑ru illustrate parent‑child relationships through their names, just as pointers reference each other.

Jin Yong often omits a name to save “memory,” treating minor characters as local variables. When a second “old man” appears, he replaces the generic term with a specific name, avoiding name collisions—mirroring how local variables prevent conflicts.

The opening of The Smiling, Proud Wanderer reads like well‑structured code: clear relationships, precise definitions, and a hierarchy that makes the story’s flow evident. Each sentence (or function) solves a distinct problem, and together they form a cohesive solution.

Complex problems require building basic models first, then gradually relaxing constraints, combining multiple models—just as good articles are multi‑threaded: a single theme with many intertwined layers, all unified under one central idea.

Jin Yong’s epic works, such as Demi‑Gods and Semi‑Devils , exemplify this: early chapters define characters and plotlines (variables and functions) that later converge in a grand climax, similar to a well‑designed codebase where all components are defined before they’re used.

Thus, applying good code style to writing means crafting clear, modular paragraphs that can stand alone yet contribute to the overall narrative, avoiding the “spaghetti” of poorly organized text.

However, not all celebrated authors follow this clean style; some deliberately write obscure code that becomes revered, showing that alternative styles also exist.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

programmingsoftware-engineeringbest practicescode stylewritingliterature
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.