Today we'll deal with a certain legend and joke among programmers. But should I even call it a legend? Indeed, among people who solve IT problems for a living this practice does show up, and although it is often treated tongue in cheek, it has its justification. And we are not talking about a specific tool installed on a computer, available online or built into electronic hardware, but about an ordinary object you can pick up, and even take a bath with.
Yes, today's article is about the rubber duck in the context of programming or, if you prefer, the rubber duck method. I haven't lost my mind. This really is a text about this topic, on the blog of a serious IT company.
What is this about? Where does it come from?!
First, let's say what this rather funny topic is all about. Programmers, like any group of specialists and people in general, run into bugs and problems that keep them awake at night. Often these are not very complicated challenges that call for huge knowledge and a lot of time spent on planning. We are mostly talking about troubles we would call "minor but annoying", and they irritate us even more when we feel intuitively that they are easy to get rid of, yet we just can't find the right path. Sometimes it comes from a lack of information, sometimes from forgetting a specific aspect, and sometimes the colloquial "brain freeze" is at work. In short, everything may be going great, and then we hit a seemingly simple obstacle that we can't get around, or even analyze properly, for a long time. It is also worth noting that we will focus on programming bugs here.
The most common way to solve such bugs is so-called debugging (in Polish called "odpluskwianie", literally "removing bugs", because the word really does come from insects nesting in old computers the size of a wardrobe). It is a process of running the program step by step (even line by line) and watching what happens underneath, that is, what values the variables take and which parts of the code we enter. This process is supported by special tools available in integrated development environments (IDE), although in simpler situations you can also reach for the classic and officially discouraged "printf debugging", that is, printing messages at the right places and watching the logs. Besides debugging there is also static analysis, when we simply read the code and review potential risk factors or the very idea for solving a given problem. We won't touch on that topic in this article, though.
Sometimes, however, debugging gives no results. Even though we see everything and feel we have all the data, we don't understand how the error can occur. Neither Stack Overflow nor ChatGPT nor any other technical help works. We even start to suspect that we don't understand the heart of the matter (we'll come back to that sentence). In a word, we are stuck. What does the stereotypical programmer do when all technical means fail? They take a rubber duck and start telling it about the situation. They discuss the problem, the input data, the expected result, the actual outcome, walk through the idea behind each piece of code, and suddenly... a metaphorical light bulb appears above their head and the solution becomes simple. The programmer thanks the duck, puts it down, fixes the problem and goes off to play CS.
Sounds absurd, right? But it works. Of course, you don't have to limit yourself to a duck or to any object at all. What matters is to understand the essence of the concept, even if we don't want to go deep into psychology and neuroscience. We won't go into detail here, but we'll share a few interesting links along the way.
Thinking out loud
We are used to reading silently. First, it is faster, and second, we don't disturb others. It is the same with thinking, where we usually don't verbalize what we arrange in our heads. This simply saves our speech apparatus and our surroundings, and it is usually enough to cope with what we meet in life. But that is not always the case: sometimes we have to engage other areas of our gray matter.
People who for years took notes by hand and later switched to digital will probably say they did it for speed (it really is faster, and after years of typing on a computer, traditional handwriting is often messy), technological availability and ease of copying. That is understandable and in most cases perfectly desirable and sufficient. However, using a traditional writing instrument and a piece of paper (at a pinch a stylus and a tablet) puts the brain to work to a greater degree, activating more complex neural connections and stimulating memory. It engages the hand (specific movements we can later recall) and creativity (every time we write the letters slightly differently, which we sometimes remember), and it also requires concentration (which again helps with remembering). And indeed, when I recall the times I studied for exams at university, I relied heavily on recalling the circumstances in which a given handwritten note was made, and during the exam itself, besides understanding the topic, I even had whole sheets of paper with my characteristic scribbles before my eyes. In the digital ("silent", more mechanical) version you can see similar processes too, but they are weaker.
Why do I mention writing at all? Because saying your thoughts out loud rests on a similar idea: we engage more parts of the body, we concentrate on what we say (verbalizing thoughts, especially in front of someone, requires speaking clearly), and we "clean up" our thoughts, which supports analyzing information and putting it together, because we simply cannot shorten our argument and skip the "inconvenient" parts that we earlier never imagined to be inconvenient.
Let's return to the sentence from a few paragraphs ago: how do we check whether we really understand our problem? Let's try to find, or imagine, a layperson and explain the issue to them (out loud). That way we analyze the topic and become aware of the gaps in our knowledge. We surely know people about whom we would say they "know the subject but can't explain it". This may point to insufficient interpersonal skills (I'll say right away, there is nothing terrible about that), but also to an insufficiently deep understanding of the area. The whole idea is that when we try to convey something to a newcomer and it turns out we can't put something into words or find an analogy, it is worth asking whether we ourselves need to learn something first and then repeat the "lecture". The more complex the topic, the better you can see it. If we can explain it so that anyone understands, it means we truly understand it deeply ourselves, because along the way we have to break many pieces down into basic parts. This is not a new concept. It is all called the Feynman technique, because the outstanding physicist and 1965 Nobel laureate was a promoter of this method.
And what if we really are explaining something to someone and that person asks us questions? Or we ask ourselves questions during the lecture, holding an imaginary dialogue? All the better. We begin to open up to aspects we hadn't thought of before, which we also have to explain somehow or take into account in design. By the way, there is a concept called active listening, which means giving full attention to the other person and what they say. Then we remember more, absorb information better, and even take body language and emotions into account and build a bond with the other person, which helps the relationship going forward. This applies to our case to a lesser extent, unless we are empathetic enough to play a nonexistent conversation partner and raise doubts to ourselves that we weren't aware of before.
To sum up this part, talking to a rubber duck while solving a problem is not necessarily a sign of mental illness, but bringing out the heavy guns of the mind to understand a difficulty and get rid of it. We pair up with the other side, and by explaining the situation to it we begin to arrive at the solution ourselves, or at least identify issues to check further. Lacking a solution doesn't have to mean we don't know what we are looking for. Perhaps during this process we realize which areas are unclear to us and what we need to learn more about.
Incidentally, after reading the last sentence some may recall the famous saying attributed to Socrates, "I know that I know nothing", and the so-called Dunning-Kruger effect, which both say that the deeper we dig into a field, the more we realize how much knowledge is still ahead of us. It is not related to rubber ducks, though. I mention it as a curiosity and to make the article look a bit smarter than it really is.
Does it have to be a rubber duck?
Of course not. The rubber duck is only a concept, almost a meme-like illustration of the other side of our dialogue, which helps solve the problem. This sympathetic (or not) bird made of a chemically derived material became part of common awareness thanks to the book "The Pragmatic Programmer: From Journeyman to Master" by Andrew Hunt and David Thomas, in which the "rubber duck debugging" technique appeared.
In truth, the best partner for solving a problem would be another person, preferably a programmer who is also fresh to the topic, not "contaminated" by our thought process, and who will look at the matter without bias, from a completely different perspective. That is, by the way, one of the arguments for another method, pair programming, as long as the partners complement each other. But we know well that sometimes you can't ask another human, or any human being at all (dogs look wise when you explain to them what is in a loop or an if). In that case we are left with an object, whose value grows if it at least slightly resembles a living creature genuinely interested in us. A teddy bear works just as well, although the rubber duck has an extra load of humor and simply a friendly look.
You can also talk into thin air, imagining a conversation partner or putting yourself in that role. If someone has a vivid imagination and empathy, it is possible, though probably less effective than channeling this "energy" into a specific object we can talk to, look at and imagine answering us, while in reality it is we ourselves who, in our heads, break the problem down into basic parts and try to assemble a solution.
Does it really work?
Yes. There are situations where a programmer is stuck and can hardly move on with "normal" methods, although, fortunately, they are rare. When they do appear, it is worth remembering the rubber duck method, even though sometimes you have to overcome some reluctance to use this psychological trick. It is worth doing, though, because you can also learn more about yourself and how you really reason about what you write in code (and beyond).
The rubber duck itself, as an object depicting an endearing bird, is also a great idea for a gift for a programmer, bringing a smile and decorating the desk. And if needed, you can even take it into the bath.
Best regards and thank you, Jakub Rojek.


