Over the past quarter of a century in which software was most of my day job,
I’ve written a fair bit of code, and read and debugged even more. Other people
have read a lot of my code, and sometimes been critical of it. As with all
things that one does a lot, the quality varies over time, but ideally trends up
with practice. A few years ago I found myself reflecting on some comments by a
coworker on specific bits of code I had written - partly my penchant for writing
zsh where others might pick python, and also on a particularly baroque utility shipped as a
docker container invoked as docker run --rm tla | sh
(where tla
is a project
specific acronym from that project) - this self re-invoking contraption writing
a suitable command line by inspecting local conditions from a stable
environment.
This post is a lengthier version of my explanation, and details a position that I have come to call The Fashion Theory of Code. The theory is that, just like fashion, there are very distinct consumers of code, and that producers of code can, and should, tailor the kind of code they write to these consumers.
Most code a professional software engineer writes on a day-to-day basis falls into the category of business attire. Exactly what that means depends on the local culture of the organisation - maybe it’s jeans and a t-shirt, or maybe pants and a collared shirt, and sometimes it’s a suit. There’s nothing particularly complex about it, and this is by design - everyone should understand how to wear it, and why it fits in. There might be some variation, and local culture shifts over time. There might be conflict and resolution about what is appropriate. Over the long run, people agree and get the job done. By and large, this is the “team written, team owned” kind of code.
For some teams, their code is more like a spacesuit. It has very specific requirements which are not common to all situations. These requirements are extreme, and require specific engineering techniques to produce good outcomes. You will not be mass-producing this code – note that in this analogy, the production is the writing, not the scaling by automated deployment. This means that you can afford to spend extra time on particular quality requirements. I’ve written this kind of code as part of virtual machine kernels, or embedded bootloaders.
Some code is like what you’ll find if you do an image search for weird catwalk fashion
for example. You’re not expected to wear this code down the street.
However, it fulfills a genuine purpose of exploration of the possible, and this
experimentation needs to happen with the constraints of actually building the
code - figuring out how to stitch it together is part of the challenge. Things
like the International Obfuscated C Code Contest fall into
this category. The docker
example above is a case where I did this, probably a
little too out of context. I claim that it is important to write such code from
time to time for the same reason that athletes lift weights at a gym – it
allows you to find the boundaries of what you can do. It is equally important to
not ship it where business attire, let alone spacesuits, are expected – this
would be akin to an athlete carrying running weights in a competitive event.
Finally, some code is party clothes. Clothes that are fun to wear. Clothes that make you happy when you put them on. Clothes that you wear so that people admire them, or sometimes ask “What were you thinking?” The clothes Harry Styles would wear on a talk show – pop that in your favourite image search. You don’t wear them to work in mundane or extreme environments. I imagine such clothes would be fun to make, although tailoring is not one of my skills, so I don’t know. I know the code equivalents are fun to write, and do their job in context, and this is where most of the shell I write for my own purposes comes from.
I’m sure you can push this analogy further – there’s probably Haute Couture code also. However, what I really want you to take away from this is the idea that thinking carefully about the kind of code you write is as much about the environment the code will be in as the code itself, and that those environments are more varied than your daily grind whether that is casual work wear or spacesuits. Find places to explore what you can do, see what happens when you do something crazy and learn from it. Above all, find places you can have fun and be yourself, and hopefully you’ll make some other people happy in the process also.