I write software for a living. Throughout a diverse succession of software projects, I have programmed in dozens of different languages on an array of computing platforms. Outside of my work life, I read books, a variety of books, including novels, classics, history, technical and scientific works, biography, philosophy. I also read software, which is not as crazy as it might sound. Sometimes there is some helpful information contained in software that I use and, occasionally, in software that I have written. Most software, of course, does not make for as interesting of reading as does most books. On the other hand, some software is highly entertaining.
Over the years (decades, actually) something has gradually worked its way into my consciousness. I have become aware that software and fiction share many similarities. In fact, in several respects, a short story might resemble a short program more than it might resemble another work of fiction.
The first way in which software resembles fiction is setting. A story has to have some context, some setting. That setting might involve place. It might also have a time aspect to it, when the story occurs. Language might also be a part of the setting. So, too, for software. Software also happens (or executes in the parlance of the computing world) in a setting, a setting both of circumstance and of time. It, too, is written in a language, a language often (but not always) suited to the circumstance and time of its execution. Different programming languages have different nuances which suit them to different types of programming. Regardless of the language or nuance, though, each program occupies some problem space, some domain, and that domain plays a huge role in what happens in the program.
Fiction also has characters. Some of the most memorable fiction has the most memorable characters. Think of some of your favorites. Software is full of characters, too. Those characters are called different things in different programming paradigms, but they are there and each one has, well, it has character. Sometimes these characters are called variables or objects or entities or whatever, but they all have some presence. They all have a role and they all behave in certain ways, although sometimes those ways are obscure and mysterious. Each one is there for some specific purpose, if it is well written software. Sometimes, though, in some not so well written software, just as in some not so well written fiction, there are some useless supernumeraries, extras, entities that tend to obscure rather than clarify the story at hand.
Of course, what would a story be without a plot, a sequence of events that transpire. Ditto for software. Software that does nothing is not really software.
Finally, setting, characters, and plot are all directed toward a purpose, both in fiction and in software. After all, a story must have a point of some sort and not just meander about aimlessly, although some fiction seems to do just that. At the bottom of it all, the function of software and of fiction is resolution of some problem or some conflict, something that needs to be set right. What might be needed is to deliver a message nearly instantaneously or it might be the hero in a novel making sense of her life, whatever. Both have to move a narrative toward a resolution. That’s what software and fiction do.