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!