Language and Thought in Coding — My Personal Manifesto

Masoud Bahrami
5 min readFeb 7, 2025

--

Opening Words

Code is a form of language, a way of expressing our understanding of the world and our attempts to shape it. Clean code is the art of clear expression in this medium, allowing us to not only build functional software but also to communicate our ideas effectively.

Language and Thought in Coding

Have you ever wondered how language can influence our thinking and the way we perceive the world around us? This is a classic question in philosophy, dating back to the very origins of thought itself: Does language precede thought, or does thought precede language? In other words, which comes first, language or thought?

Which comes first, a language or our thoughts?

We know that writing is an effective way to ensure whether we are actually thinking, or just think we are thinking! In essence, writing and written form are a verbal form of what exists in our thoughts. And to write, we need a language. So:

Language influences our way of thinking => To be sure that we are thinking, we need to write => To write, we need a language => …

This suggests a reciprocal relationship: language shapes thought, and the act of writing further refines it.

Of course, this does not mean that clean code has no connection to the language of the machine. Ultimately, the code must be executable by the machine. However, my emphasis is that clean code should primarily be understandable to humans, and this is achieved by writing the code in the language of the problem domain.

Writing and Thinking

Writing is a powerful tool for clarifying our thoughts. The act of putting our ideas into words forces us to examine them more closely and identify any gaps or inconsistencies. Similarly, writing code helps us solidify our understanding of a problem and refine our approach to solving it.

Clean Code as the Language of the Problem Domain

Given this, as we can see, writing can also influence our thoughts. Code is a form of writing; a written form of a problem statement or a solution to that problem. There are various definitions of clean code, but I believe that clean code is code that is written in the language of the problem and its domain. If code is to serve as a solution related to the problem statement, and if we have once tried to understand the problem statement, then it is much better that this code be written in the same way.

There are various definitions of clean code, but I believe that clean code is code that is written in the language of the problem and its domain. If code is to serve as a solution related to the problem statement, and if we have once tried to understand the problem statement, then it is much better that this code be written in the same way.

Clean code is code that is written in the language of the problem domain. It uses terminology and concepts that are familiar to those who understand the problem, making it easier for them to read and understand the code. This is in contrast to code that is written in the language of the machine, which is often cryptic and difficult to decipher.

Example

Consider the following C# code snippet:

public static bool AreWeAllowedToSellThe(Flight readyToSellFlight, Passengers passengers)
{
if (ItIsNotADomesticFlight())
return YesWeAreAllowed();

if (TheExpectedFlightIsNotEconomical())
return YesWeAreAllowed();

if (TheExpectedFlightIsRoundTripAndIsNotOfferedByASimilarAirline())
return YesWeAreAllowed();

var sellingPriceOfTheFlightSetByAirline = GetRule();

return WeHaveNoRestrictionsOnSales()
|| CheckAreWeReallyAllowedToSellThisFlight();
}

This code is clean because it expresses the logic of the problem domain directly. It uses terms like “domestic flight”, “economical flight” and “round trip” that are familiar to anyone who understands the airline industry. This makes the code easy to read and understand, even for those who are not familiar with the specific implementation details.

Beyond Conventions

While naming conventions and style guides are important, they are not the only factors that contribute to clean code. Clean code is also about clarity of thought and expression. It’s about writing code that is easy to understand, maintain, and extend.

A Note on Naming Conventions

One common principle of clean code advocates for method names to be in the form of a question. This aims to improve readability and comprehension. However, there are instances where adhering strictly to this convention might not be the most effective approach.

In the provided code snippet, the YesWeAreAllowed method deviates from this convention. It’s not posing a question; rather, it’s making a statement. In the real world (the problem domain), the concept of “being allowed” might be an announcement or a declaration, not necessarily a question. By naming the method YesWeAreAllowed, we are reflecting this fact within the code.

This highlights a crucial aspect of clean code: it’s not always about blindly following conventions. Sometimes, prioritizing the clear and direct expression of the problem domain takes precedence, even if it means deviating from established norms.

Clean Code: My Personal Manifesto

Code should speaks the language of the problem, not just the language of the machine, to facilitate collaboration and maintainability. Clean code is more than just following style guides or naming conventions. It’s about expressing the problem domain clearly and directly in the code itself. It’s about writing code that speaks the language of the problem, not the language of the machine.

Closing Words

Clean code is more than just instructions for a machine; it’s a dialogue with the problem itself. By writing clearly, we not only build better software, we build a deeper understanding of the world around us.

--

--

Masoud Bahrami
Masoud Bahrami

Written by Masoud Bahrami

DDD teacher and practitioner, software engineer, architect, and modeler. Specialized in building autonomous teams and services.

No responses yet