Like IceCream on Steroids — You’ll Never Do Print Debugging Again

Just as there are stages of grief, there are stages of debugging. Stage 1 is just looking at your program trying to figure out what is wrong. Stage 2 is adding print statements in your code to print out key values. Later, you might switch to an actual debugger, but that’s often too heavy for simple projects so sometimes stage 4 is going back to print statements.

However, you wind up doing print statements, you’ll probably discover something like IceCream that makes it easier (if you haven’t found IceCream check out Khuyen Tran’s post on the tool).

Then there’s stage…


Threading can be easy, but not that easy…

Most modern computers have multiple processors or, at least, a fast context switch for a single processor. Even if you have one processor, there will be a lot of time it doesn’t have anything to do but wait for one program and it can service another. To take advantage of this in your own programs you can use threads. But there are several tricky things about threading you need to think about when designing software to take advantage of this.

Exactly how you create and manage threads will depend on the language…


Is there nowhere gdb can’t go?

Unless you are superhuman, you’ll have bugs in your program. Many times you can use print statements to figure it out, but that’s not the best idea. Instead, you want a debugger. If your IDE provides one, it is probably only a shell around the venerable gdb software (the GNU debugger). This simple tool can be a little intimidating, especially the command line interface.

However, there are a few tricks you should know. This isn’t a tutorial about using gdb — there are plenty of those like this one from Amit Kulkarni.

Even bare gdb can have a GUI

If you…


Learning a language is great, but you also need to learn your tools

There’s an old joke about a man who goes into a hardware store complaining he has to chop down dozens of trees in his back yard. The woman who owns the store tells him he needs a chainsaw. The man is resistant so she says, “Tell you what. You take the chainsaw home and if you don’t like it bring it back tomorrow. But if you do like it, you can come back tomorrow and buy it.”

The next day the man comes in very upset. “This thing is stupid. I only got two trees down yesterday and it was…


Python, C++, JavaScript… none of those will make you a programming hero

Imagine you decide you want to write novels so you enroll in a class. On the first day, the instructor says, “Tolstoy, Nabokov, Dostoevsky, and Chekhov. These four authors are considered among the greatest novelists of all time and they are all Russian. Therefore, you are going to learn Russian which will let you also write a great novel.”

I hope you’d get up and leave. A great novel isn’t Russian or English or French. A great novel has many elements that you could express in any language. But we see this all the time in programming. You want to…


I’ll admit it — I usually do quick and dirty JavaScript, do you?

I’ve written a lot of code over my career and most of it has been in “traditional” languages like C, C++, Java, and more. I have to admit that JavaScript, to me, gets shorted. It is easy enough to just go belt out a few lines of JS and if you know Java or just about anything else, you can usually figure it out, maybe using Google to help with anything tricky.

But that’s not always the best approach. But what do you do? As an experienced…


Work Smarter not Harder

There’s an old saying you can’t be too rich or too thin. However, in programming terms, you might say you can never be too small or too fast. Many programmers obsess over every byte and cycle of their programs, sometimes with good reason. But it turns out, the biggest gains are often not from optimizing your existing code, but from challenging your algorithm.

One of the best examples of this is an old story about the mathematician Gauss. In elementary school, his teacher wanted a break and told the class to add the numbers from 1…


If one terminal is good, many terminals must be better…

If you use the Linux command line, you are probably concerned with getting things done quickly and easily. It is easy to get spoiled having multiple terminals open on a GUI desktop, but that’s not always possible or desirable. However, Linux — and Unix in general — can easily make one terminal screen support multiple sessions at one time. There are a few tools to do this, but a key one is tmux. …


Happy holidays with no GUI required!

While not everyone celebrates Christmas, everyone can still appreciate a beautifully decorated tree, especially if there are presents underneath. If you don’t have enough space for a real tree, you can always put one up in your terminal window, thanks to a clever bash script from Sergio Lepore. Even Windows users can get in on the act thanks to things like WSL and Cygwin.

It also is a fun little script if you’d like to try your hand at customizing a bash script. …


Emacs, VIM, Wordstar… take your pick.

Uh oh. You just logged into a docker instance (or a Raspberry Pi, or a server, or your latest Linux-based home automation gadget). You went to call up your favorite editor and, of course, it isn’t there. Sure, you can install vim or emacs or even something like VSCode, but those are all giant editors with tons of libraries and dependencies. Why not try E3? Don’t want to learn yet another editor? You don’t have to. E3 can impersonate emacs, vi, Pico, Nedit, and — no kidding — WordStar. …

Al Williams

Engineer. Author. Team Leader. Lots of other things. I blog about hardware hacking for Hackaday (www.hackaday.com), but talk about other topics here.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store