I am unsure how to ask this but here goes: I am having difficulty debugging my code. Coming from a MATLAB background, I am used to a very smooth debugging experience. But with Julia, I’ve tried using the Juno debugger and it’s very slow. So mostly I end up copy pasting functions in a new file, removing the top and bottom lines (function x(a,b)
and the end
statement) and then set inputs manually and go line by line until I get to the point that needs to be debugged. Checking loops with print statements, etc. Ultimately I paste the correct code into my module/package and restart Julia and test it.
It gets the job done but very messy, and I feel there must be better ways of debugging. Am I just doing it wrong? What are some good debugging workflows?
1 Like
Did you use the compiled mode
checkbox? I use it all the time and it’s pretty fast. Of course, in compiled mode breakpoints work only in the current function, and I do a lot of next line
and step in
, but I got used to it. You can also switch between compiled
and interpreted
if you want to set a breakpoint somewhere deep in the code, but you need to be a bit more patient with the interpreter until it gets there.
The only situation where debugging is slow for me is when I debug the backpropagation pass in Knet on a gpu.
Edit: in compiled mode you might have the impression that things are a bit slow if you’re debugging a function first time because it’s also compiling it. In these situations I look at the progress bar in Juno at the bottom left and wait for it to finish. Sometimes it doesn’t show up until I click somewhere in the file I’m debugging.
Another quirk of Juno is that it always starts the debugger in interpreted mode, so you have to exit debugging, click the checkbox and enter again. You will see the REPL in blue instead of yellow and know you’re in compiled mode.
3 Likes
Yes, Juno debugging is powerful, but the UI sometimes overwhelms me too.
1 Like
I know about it, but it caused me trouble at some time (can’t recall what exactly) and I didn’t try it again. Okay, thank you—I’ll give it another go. I just wanted to do a sanity check in case most people were using a different means of debugging in general or using print statements etc.
You might try the Debugger package. I wrote up a brief intro.
2 Likes
Thanks for this, it’s great. I’m not a programmer and debuggers always seemed a little to daunting for me, but I needed something like this tutorial for Julia.
1 Like