Debugging with audio

echo "here";

Sometimes you just want to know that you took the right branch in an if statement, or that the value of a variable is what you expect it to be. Sometimes you don’t have the need, time or incentive to fire up the debugger, you just want to dump a few variables to stdout. That works really well if you’re writing a CLI script and it’s okay if you work on old-fashioned HTML, but when it comes to debugging AJAX requests, it’s pretty useless. When the response comes back to the browser you have to open up the web inspector and look at the network activity to find that particular requested document, click to look at the contents and dig out that debug message from the raw source. Not fun.

A few weeks ago I was doing just that. I was submitting stuff to the server without any direct confirmation to the user, and I needed to know that this stuff was getting there alright. The logic was really simple, so proper debugging felt like overkill. I could have written to a log file, but that meant I would have had to use my eyes to read that file moments later. My eyes were busy reading code, but my ears were idle. I wrote a small function that spat out a string to a temp file, and a tiny daemon to espeak the contents of the file. It was very crude, but it worked.

Since then I’ve been using audio debugging all the time, and I’ve more or less integrated it into my normal development workflow. Not only does it make debugging AJAX requests easier, it’s also a lot less intrusive when working with synchronous content. In PHP, if you try to dump a variable before an HTTP redirect, it usually breaks execution. An audio “dump” doesn’t. Anything you just echo out on screen tends to break the layout and sometimes get hidden behind other elements – audio debug messages could drown your Spotify background music, at worst.

For me, audio debugging is really useful since it allows me to involve another sense into the development process. It just makes me wonder what other senses one could get in there. What does an undefined variable smell like…?

Latest News & Insights

Say connected – get Loft updates straight to your inbox.