Code as a Story: The Narrative Essence of Programming


In the vast realm of computer programming, where lines of code create the languages spoken by machines, an unexpected parallel emerges — a striking resemblance to the art of storytelling. I began my place in programming actually in the space that is social sciences (I studied political science…and physics, admittedly, in university…perhaps that is why I’m taking this approach to explaining the parallels). I actually found the similarities to be quite easy to draw but, also, necessary for those that think less…numerically.

Now, I’ve read articles in the past the have a similar concept (coding as storytelling) but, I found they were a bit cursory and so I shall…digress. The process of coding, in its essence, embodies the essence of a narrative, complete with themes, characters, settings, chapters, stylistic devices, and even dialogue. By peering through this narrative lens, we can unravel a deeper understanding of the creative process that underpins the craft of programming/developing and, maybe, even inspire a few folk who may have otherwise given up or moved on because of the inherent challenges.

Firstly, coding is a challenge for EVERYONE!

I have a great memory (except when I am looking for my car keys evidently) but, remembering all the ways in which to execute and manipulate stuff in code can even escape me. It can escape anyone. I have some friends who have come back from vacation and felt like they might as well start working in a whole new industry. Maybe if anything this simply brings to the surface a tacit collective compulsion to maintain mastery. We’re egomaniacs. I sense it is axiomatic, and, something I just can’t shake. Be easy on yourself especially if you’re just starting out.

This article is meant to REASSURE, and maybe even invoke some insights. There’s plenty of things in the coding process that feels like one is actually writing a story. Let’s explore some elements:

Different Languages

There are tons of development languages out there, such as Java, C, C++, Python, Bash, HTML, CSS, JavaScript, Rust, Swift, Dart, SQL, and more. Intuitively, it may seem like languages in coding (if we’re thinking about this from the perspective of storytelling) are spoken languages (i.e., English, Spanish, French, Hungarian, etc.). However, I believe they more closely resemble the genre of a book. Let me explain.

Languages can, more or less, communicate the same concept adequately. That is to suggest that it would be remiss to say one dialect is or was designed to do one thing better than the others or that only it can do certain things. Well, in the development space, that is precisely the case. Try making a relational database with HTML, JavaScript, or C#, or try making an augmented reality app with Ruby, or a complex 3D game with Flutter. Typically, these languages are blended together to create one application or experience, and that one application is the genre of a book, such as a video game, a website, a SaaS, etc. might be equivalent to mystery, history, or manual style of books (not making a direct comparison here).

Themes in Code

Much like a story carries underlying themes that shape its narrative, code encompasses fundamental concepts that drive its development. Themes in code could be analogous to the message or moral of a story. Whether it’s optimizing for efficiency, enhancing user experience, or ensuring scalability, these themes serve as guiding principles — just as the central themes do in a captivating tale. Perhaps you can think of these as the guiding principles (a bit tricky) or the thing that gives direction to the development process (this one isn’t represented by an exact line of code but, like the external structures like efficiency and readability).

Characters: Protagonists, Antagonists, and Sub-Characters

In the narrative of coding, characters manifest as the building blocks — the ‘variables’,’ functions’, and ‘objects’. The protagonist, often resembling the main function or core algorithm, propels the program forward toward its objective. Of course a good character requires description so all the things you put inside of the function are like the qualities, relationships and backstory of the character. Conversely, the antagonists are the bugs, errors, or challenges that the code confronts, akin to a coder’s or application’s adversaries. The sub-characters play a supportive role — functions or modules that assist the protagonist (main function) in achieving the end goal.

Settings in Code

Just as a story’s setting lays the foundation for the plot, in coding, settings represent the environment or platform where the code operates. The technology stack, the operating system, the hardware configuration — all contribute to the ‘setting’ of the code, significantly influencing how the ‘story’ of the code unfolds.

Chapters: Organizing the Narrative

Chapters in a book provide structure, allowing for a logical flow of events. Code follows a similar principle — it’s organized into modules, functions, and classes, each functioning like a chapter in a book. Each section of the code unfolds a crucial part of the narrative, contributing to the overall story of the program.

Stylistic Devices: Code Aesthetics

Much like a writer employs literary devices to enhance a story’s appeal, a programmer uses stylistic devices to make the code efficient, readable, and maintainable. These include comments, indentation, proper naming conventions, and design patterns. These ‘stylistic devices’ serve to enhance the readability and functionality of the code, akin to how metaphors and similes enrich the language of a story.

Script or Dialogue: Code Execution

In a literary context, dialogues are vital — they advance the plot, revealing characters’ thoughts and motivations. Similarly, the script in code represents the execution — commands, instructions, and interactions that dictate the program’s behavior. The script brings the code to life, allowing it to communicate with users and other systems, much like dialogues advance a story.


In deciphering the essence of programming, it becomes evident that coding transcends its functional nature. It is a form of storytelling — a medium through which narratives of innovation and creativity are crafted. By understanding and embracing this narrative perspective, developers can elevate their approach to programming, enabling them to create not just functional code, but tales of ingenuity and brilliance. If you can think of coding more like story telling where you get to create your characters (‘functions’) and place them in a setting (‘environment’ such as c# and reference a c# library) and use a form of describing the story (your stylistic devices and code readability) you’ll be far more capable as a developer (new or senior), especially if you have to explain and document your code.

Created using Figma
Purchase template