How do you use debuggers?

How do I know you didn’t miss any details? Trust you, because you’re an authority in the subject? You already typed everything down into the REPL, so copy pasting that into a script and putting a test on the end to make sure it actually outputs the result you think it does takes less than a minute. I don’t understand why someone wouldn’t want to make it easy for someone else to run their exact computational analyses to make it easy to reproduce every figure with 1 button and enough computing resources.

(I really applaud Fernando Perez was mentioning about the new tools to accommodate reproducible science and make this easier, https://www.youtube.com/watch?v=DUdE3M2nlDE&t=1s . I hope this becomes required.)

Linking back to the original purpose of this thread, test suite are the best debugger because humans are infallible and get things wrong. Tests get corrected and refined over time. Other people check them, ask questions, and make sure try to re-understand them (maybe you in the future!). What you type into the REPL is something you did once, and sometimes your recall of it is wrong. We’ve all typed things into the REPL and been like “huh? Oh… I renamed …” or something silly like that, because we are all fallible. We all write bad code, and we all write code incorrectly. Tests are a clear statement of what you’re looking at, and it allows others (or you in the future) to double check no only that you’re looking at the right thing, but also that you’re looking for the right thing. Hell, one instance of this was already documented earlier today:

What I was throwing into the REPL was wrong because I’m silly and fallible, but my tests still led me to the right spot and uncovered a Base bug.

The only reason to have complete trust in what you do interactively is if you never make mistakes, but if that’s the case, why would you need a debugger?

6 Likes