Have you ever noticed a rubber duck sitting on a programmer’s desk and wondered what its purpose is? You might think it’s just a quirky decoration, but there’s a practical reason behind why many programmers keep a rubber duck close at hand. This blog post will explore the fascinating world of rubber ducks in programming and their role in helping programmers write better code. So sit back, relax, and let’s dive into the curious case of the rubber duck.

Programmers are constantly running into issues in their code. So, most programmers use the rubber duck debugging method. With a rubber duck, you explain the problem you’re facing to the duck, and in return, you find the solution by just explaining the situation out loud. Teaching forces you to evaluate issues from a different perspective and helps provide a deeper understanding, especially in programming. Although this is famous for programmers, anyone can us them in any industry. Rubber ducks are also fun to smash.😁

Why are rubber ducks so popular?

Rubber duckies have been famous to humankind since 1940. It was the first adorable yellow bathing toy made by a sculptor named Peter Ganine. He was having trouble selling his sculptures, so he came up with a solution; why not sell them as toys?

The initial version of the rubber duckie was not made out of rubber like present-day ones. Instead, it was plastic. These ducks were very popular, and they sold 50 millions of them back then.

Eventually, they made their way into the bathrooms. Ernie from the popular kids show Sesame Street significantly increased the rubber duckie’s popularity in one particular episode; Ernie sings a song about his small yellow friend (rubber duckie) with lyrics like it makes bath time lots of fun.

Nowadays, rubber duckies are known worldwide as standard kids’ toys. Some people suspect that Queen Elizabeth II had a rubber duckie with a crown when she was younger. There are also rubber duckie races, with England having the most significant race yet. In fact, there are several other floating rubber toys with shapes different than ducks, like octopi. But as Ernie says, we’re awfully devoted to rubber ducks.

What is rubber duck debugging?

When you’re coding, the one thing we know for everybody, regardless of experience, is that YOU WILL GET STUCK. There’s no problem that you can solve immediately. Whether you’re a seasoned programmer or code noobie on your second day of learning to code, you will get stuck. You’re looking for a way to get unstuck. And one of the techniques that’s very popular is rubber duck debugging

So, you’re writing code, building a project, and running into a problem you just can’t figure out. You don’t know why it doesn’t work, there’s no compiling, or it’s not behaving as expected. What do you do? You get up, you walk out the hall, you chat with your co-worker, and you’re willing to talk about the problem to solve it anyway. The moment you start to talk about the problem you’re facing, you realize that the answer is so close; you just have to say it aloud and look at it from a different perspective. That’s rubber duck debugging. Instead of bothering your teammates or other people, you can explain your problem to a rubber duck. 

How does this really work? How do we fix a problem by simply explaining it to a rubber duck? Why do programmers have rubber ducks? It’s fascinating that you can fix an issue you’ve been struggling with for the past 3 hours by just saying three sentences and explaining it to someone else. Here is why: explaining something to someone else, even an object like a rubber duck, forces you to slow down and explain the problem fully. So, if you’re talking to another human, they need context. You have to explain the whole concept of what you’re trying to do and the complete knowledge of the problem.

On the other hand, if you’re explaining your problem to a duck, they don’t know ANYTHING about coding; therefore, you must define the entire issue. That allows you to start at the top, work down to the things you know, and explain it thoroughly until you get to the piece of code that causes the problem. And suddenly, it will pump to you like that.

You see, this happens in a lot of ways in life. The brain works some things in the background, even though you’re not consciously thinking about it. Also, sometimes we think about something consciously in coding, and that act gets in your way of fixing a problem. So, focused on the tree you’re looking at, you can step back sometimes and look at the whole forest. And explaining that to someone else or a rubber duck makes you do that process. Have you ever wondered why are rubber ducks yellow? You can also find the answer to this in our blog.

Rubber duck in programming

Programmers stay all day at the desk and code games, apps, and websites for us. You can hire a programmer anytime to take care of all kinds of programming jobs; with or without a rubber duck. Sometimes, they also get angry and start saying words that a simple human like us can’t understand. When coding, the probability of you making mistakes is high. Each of these mistakes can introduce a bug that prevents the entire program from starting. Or even worse; it will stay silent and start crashing things after the releasing the program.

So, what does a programmer do when there is a bug in the code? Of course, cursing and hitting the table is the first thing to do. Next, the programmer will try to find the bug, and finding the bug in the code is pretty tricky because you can’t see it like you see a bug on the table.

You often have to run the program multiple times, change the inputs, modify the code, and test again. Then, pray, and in the end, call a friend to look at your code. But calling someone multiple times and asking them to check your codes may be disturbing. That’s why someone came up with this bright idea. You can easily explain the code to a rubber duck line-by-line. It can’t run away; it’s always there for you, and most importantly, many programmers noticed that while you explain your code to someone else, you usually discover the solution yourself.

Why does it work? Well, when describing your code to someone person or a rubber duck, you typically tell them what the code does and what are the functions. It’s pretty simple to detect and correct what’s not working well. This works for other sciences as well. Also, next time you can’t understand a math problem try explaining it to someone or something else. When teaching something to someone, you have to evaluate the subject from different perspectives. And that’s why rubber ducks in coding play an essential role. This can provide a deeper understanding and even help you solve your problem.

How useful was this post?

Average rating 5 / 5. Vote count: 2

No votes so far! Be the first to rate this post.



Please enter your comment!
Please enter your name here