Good code and Plato’s world of forms

Roman Suzi
3 min readSep 10, 2022

A friend of mine asked whether I see a connection between Plato’s solids and ideal computer code, and here goes my answer.

Photo by Milada Vigerova on Unsplash

Speaking metaphorically, if the requirement is to maximize volume of a jar while saving material, then a sphere is probably the best form for this. However, humans need handlers to be added and also the jar should have a hole for the liquid. The same is true for software. Ultimate optimization brings ideal structures, but practical needs distort the beauty. Also, not to forget that there is a development time dimension to it. Suboptimality may be accepted when the time of development is tailored in (Hmmm…. multidimensional sphere?). However, drawing a square instead of a circle due to lack of skills is a bad excuse for not having a decent design.

Humans are very complex systems based on many layers of subsystems, so the Platonic world may look much more complicated than circles and squares. Yet humans understand simple forms better, so software is driven by a contradiction of doing complex things (which reflect some part of reality — our problem domain), but need to present this in an adequately simple form for humans (solution).

Good code is also an artifact written for humans to read, so its resemblance to Platonic forms is surely desired. At least I never heard Plato mentioning spaghetti. Thus the code needs to be human readable and be of minimal length: two opposite forces.

It is true for the 95% of the code most web or application developers deal with. For scientific research the computer code may be a derivative from some mathematical equations and it’s not the real source code then, albeit even mathematicians strive for simpler concepts over time. Quicker matrix multiplication algorithm may help to squeeze all juice out of CPUs, but will not necessarily be simple due to taking into account some specific properties of the problem at hand like some specific sparse matrix form.

This is very much the debate on what is discovered vs invented. By saying “up to isomorphism” mathematicians make results look like discoveries, not inventions, though it may take some time to… discover distant connections in different branches of mathematics.

Having to supplement client’s stories with additional features pretty much aligns with abstract algebra and category theory: you get some puzzle pieces from the client and then fit them into the minimal (mathematically) meaningful structure. For example, if you have C for CRUD implemented, you probably want R as well unless you are sending a message to another star system… That is, if you have concatenation, then most probably you should also have an empty string, reinventing the monoid. This is how blindly following YAGNI (“You aren’t gonna need it”) principle is, well, naive.

That is why good software programmers visit Plato’s worlds often. Sometimes ideal forms found there can satisfy everyone including the end user, providing a fresh and simple mental model for the solution. Using ideal forms in the source code has a positive impact on the quality of software anyway.

--

--