October 8th, 2024

Caveman Debugging in the Modern Age

Caveman debugging uses print statements to track code execution. Integrating it with IntelliJ IDEA's Live Template feature enhances productivity through custom templates, streamlining repetitive tasks and improving coding efficiency.

Read original articleLink Icon
Caveman Debugging in the Modern Age

Caveman debugging, or "printf debugging," is a fundamental method for debugging code that involves inserting print statements to monitor program execution and variable values. This technique, highlighted by Brian Kernighan in 1979, remains effective today. The article discusses the integration of caveman debugging with IntelliJ IDEA's Live Template feature, which allows users to insert predefined code snippets quickly. The author shares two custom live templates that enhance productivity: one for printing class and function names and another for measuring execution time. These templates streamline the debugging process, reducing the time spent on repetitive tasks. The author encourages readers to analyze their workflows to identify repetitive coding patterns and create custom live templates tailored to their needs. This approach can significantly improve long-term productivity in coding. The post concludes with an invitation for feedback and sharing of additional live templates.

- Caveman debugging involves using print statements to track code execution.

- IntelliJ IDEA's Live Template feature allows for quick insertion of code snippets.

- Custom live templates can enhance productivity by automating repetitive coding tasks.

- Analyzing personal workflows can help identify areas for improvement in coding efficiency.

- The author invites readers to share their experiences and templates for further discussion.

Link Icon 4 comments
By @satisfice - 6 months
Ever since I was gifted with a Kontron chip emulator debugger for my work in Assembly language, and enjoyed total control over my universe, I almost simultaneously discovered that using it greatly slowed down my debugging. It made me lazy. I bet Sauron would have won MiddleEarth if he wasn’t so hung up on his Palantir stone.

Ever since, I redoubled my effort to use my brain for debugging, plus simple print statements and logging. Only when I am ready to jump out a window do I fire up a debugger.

(BTW, for three years I was in charge of the Borland Turbo Debugger test team.)

By @invalidname - 6 months
You're already using IntelliJ just use tracepoints and get a ton of advantages without forgetting prints in production. Stop living in the 70s, that quote makes sense when you're building a kernel not a modern user space app.
By @dlachausse - 6 months
I never heard it called caveman debugging before but I love the name.

I am a huge fan of print debugging. Debuggers have their place, but most of the time print is just easier and it fits better into my mental model.