What Is Rubber Duck Debugging? (Why Every Dev Should Have a Duck)

Updated on | Sign up for learn to code tips


You might have seen programmers keeping rubber ducks on their desks. (See if you can spot the one in this tweet, for example!) But what on earth is the connection between a rubber duck and programming?

Well, itā€™s all thanks to a concept called the rubber duck debugging method, or rubber duck programming.

Many coders keep a rubber duck toy on their desk as a reminder to talk through things and simplify problems. They explain the problem theyā€™re facing to the duck, or another inanimate object, out loud.Ā 

When youā€™re breaking down problems and explaining code line-by-line to a friendly duck that wonā€™t judge you, it can help you see things from a new perspective. Rubber duck coding can help you find better solutions, think of easier algorithms to implement, etc.

In this post, learn more about what the rubber duck debugging technique is, where it came from, why and how it works, whether you can do rubber duck debugging without rubber ducks, and where to get your own coding rubber duck to join your desk decor!

Disclosure: Iā€™m a proud affiliate for some of the resources mentioned in this article. If you buy a product through my links on this page, I may get a small commission for referring you. Thanks!

What Is Rubber Duck Debugging?

šŸ¦† Rubber duck debugging (sometimes shortened as rubber-ducking) is a technique for debugging. The main idea behind it is that speaking out loud can help you solve problems.

What exactly is the function of a rubber duck for coding?

Coders use a rubber duck in programming (or other toy, stuffed animal, pet, inanimate object, etc.) because itā€™s a small object that doesnā€™t bother anyone and can always sit on your desk as a reminder.

The duck serves as a way to help you externalize thoughts and work through a problem step-by-step, explaining each line of code and its purpose out loud in simple terms.

rubber duck

As Scott on Twitter says, ā€œI can’t count the number of times I’ve called over a colleague to explain an issue I’m having to ask for help and then halfway through saying ā€˜…oh, wait. Now I understand!ā€™ without them saying a word.ā€

By using your handy debugging rubber duck, you donā€™t have to interrupt any coworkers, and you donā€™t have to look crazy by just muttering to yourself. Instead, if anyone overhears, you can hold up your little friend and tell them ā€œIā€™m rubber duck debuggingā€”itā€™s a thing!ā€

Of course, if a coder still canā€™t figure out a solution after explaining it to the duck, they can then ask others for help. The rubber duck debugging technique is just a great starting point to get you thinking out loud.

Start coding now

Stop waiting and start learning! Get my 10 tips on teaching yourself how to code.

Don't worry. I'll never, ever spam you! Powered by ConvertKit

Where Did Rubber Duck Debugging Come From?

The origins of rubber duck debugging can be traced back to the book The Pragmatic Programmer: From Journeyman to Master by Andrew Hunt and David Thomas, which was first published in 1999. 

In that book, thereā€™s a story that talks about how a programmer carries around a rubber duck and explains their code to it when they encounter a bug. The authors describe the technique as a way for developers to externalize their thoughts and better understand their code.

two rubber ducks

The term “rubber duck debugging” was coined in the early 2000s, and it has since become a widely recognized term in the software development community. It is often used humorously, but the rubber duck debugging method itself has proven to be an effective way for developers to catch errors and solve problems.

Ever since then, software engineers have used their own programming rubber ducks (and other objects) to help them think through code.

Rubber Duck Debugging Method

Rubber duck debugging is super easy. Here are the steps:

  1. šŸ› You have a bug, and the regular investigation process isnā€™t working for you to track it down in your code.
  2. šŸ¦† Find your coding rubber duck and put them front and center on your desk, ready to get to work! (You could also recruit another inanimate object, a pet, or even a human friend.)
  3. šŸ—£ļø Explain the code line-by-line to your duck. Talk about why you coded something a certain way, what your goals are for the code, etc. The process of having to organize your thoughts and speak out loud can often make something ā€œclickā€ in your brain. Try to explain your code or the bug as if youā€™re speaking to a child, or a duck that doesnā€™t understand code at all (which, after all, most ducks donā€™t!).

If there are times when the rubber duck debugging technique doesnā€™t work, then you can always ask other programmers for help. But since most developers prefer to spend some time doing their own troubleshooting first, having a helpful rubber duck for coding could be just the thing to lead you to a breakthrough.

Why Does Rubber Duck Debugging Work?

Even just having a rubber duck on your desk can help you solve problems! Here are some thoughts from coders on Reddit on why rubber duck coding works for them: 

  • strigonian: ā€œIt helps protect you from making the mistake of skipping over “obvious” bits of code. People usually have a tendency to assume that certain parts are so simple or straightforward that they can’t possibly be wrong, so they shouldn’t waste their time scanning these bits. Explaining it to a ā€˜duckā€™ helps to override this problem, because your ā€˜duckā€™ doesn’t know anything, so nothing is obvious to the ā€˜duckā€™.ā€
  • hollammi: ā€œSpeaking out loud is a fundamentally different process in your brain, e.g. it’s much easier to memorize information by repeating it aloud a couple times.ā€ 
  • PC__LOAD__LETTER: ā€œA lot of the time I end up answering my own question by going through the process of explaining what Iā€™ve tried and what Iā€™m confused about.ā€ 
  • ElephantRyan: ā€œI keep a small black rubber duck at my desk as just a reminder that the solution is usually in my head. I just need to slowly work through the problem. He’s my little motivation!ā€

Science backs up the concepts behind using a rubber duck in programming, too! According to a study conducted by Gary Lupyan at the University of Wisconsin, self-talk helps boost your perceptual processing abilities.

Start coding now

Stop waiting and start learning! Get my 10 tips on teaching yourself how to code.

Don't worry. I'll never, ever spam you! Powered by ConvertKit

Does It Have to Be a Duck?

Despite its name, you can absolutely do rubber duck debugging without rubber ducks involved at all! You can use anythingā€”a toy, pet, stuffed animal, baby, etc! šŸ±

Here are just a few examples from coders on Reddit and Twitter:

If a programmer rubber duck doesnā€™t feel like the right fit to you, think of what would make a good ā€œcoding mascotā€ that fits your personality!

cat on a laptop

Where to Buy Ducks for Rubber Duck Debugging

Want to go with the ā€œtraditionalā€ rubber duck for coding route? Hereā€™s a quick list of some of our favorite programming rubber duck options:

various rubber ducks

While it may seem a little silly when you first hear of it, rubber duck debugging has become a widely recognized and accepted technique in the software development community, and it is likely to remain a valuable tool for developers for years to come.

Give it a try yourself to see why!