Philosophy in Programming

Philosophy. Morality. Utilitarianism. Deontology. These can be pretty heavy stuff, and so abstract that they don’t even seem real. Maybe it would help if we tried viewing these concepts in a completely different setting… such as computer programming.

Act Utilitarianism: How you write code does not matter at all. The only thing that matters is program behavior. Commenting, indentation, variable-naming, breaking down complex code into simple functions… these are all things that don’t affect program behavior, so they don’t matter. As long as it produces good program behavior, write code anyway you like.

Rule utilitarianism: The ultimate end goal is good program behavior. However, as imperfect programmers, we can never know when something will produce downstream complications, bugs or unexpected program behavior. Hence, always write code using coding guidelines that are known to produce good program behavior.

Immanuel Kant: Program behavior does not matter at all. You should never write code as a means to some other end such as program behavior. Writing code using coding guidelines should be an end in itself. A good coding guideline is one that everyone can universally follow, without contradictions. These coding guidelines are intrinsically good in and of themselves, independent of practical benefits or outcomes.

Aristotle: Code wants to be written in a good way. Writing good code makes one a virtuous person. Hence, to be a virtuous person of strong character, you should write code in such a good way.

Religion: On the 1st day, God created the microprocessor. On the 2nd day, he created the OS. On the 3rd day, he hibernated. Seeing that the OS was running wild, he sent his son Jesus.exe, the only program to be compiled without source code. And Jesus said to his followers: “Thou shalt follow type safety, and if you don’t, I shall place a curse upon you.” Anyone cursed shall first see his programs leak memory & fail. Then he shall be fired by his boss. And if he still does not confess & repent, he shall be doomed to suffer in unemployment for the rest of his days.