Be Mad: Stacktraces are All Upside Down

This is a blog about the development of Yeller, The Exception Tracker with Answers

Read more about Yeller here

So imagine you’re sitting programming in your terminal, and you cause a new bug in a unit test. This is normal, it happens hundreds of times a day. You reach for your mouse and start to scroll up to the top of the stacktrace to figure out what’s up.

Wait, what the fuck?

Why do you have to scroll to see the error message, and where it actually happened? (As opposed to glibly staring at the start of your test runner and your application code).

Your Stacktrace is upside down

And not just yours. Many major programming languages get stacktraces the wrong way up:



Clojure (and all other JVM languages)

Millions of programmers waste a few seconds every minute or so, because nobody ever thought about basic usability in their language.

Now, some tools will shorten your stacktraces, which drops a whole bunch of information. This isn’t any good though - whilst you don’t usually need that information, sometimes you do.

How Stacktraces should be printed

Python is the only major language that gets this right. Here’s what a stacktrace looks like in Python:

The error message is printed right at the bottom, and then the rest of the stacktrace goes above that, with the deepest frame first. You don’t need to scroll to see what caused the error at all, you don’t need to reconfigure your test runner, and you can just scroll straight up if you need more history (but often you won’t).

Why Stacktraces Are Upside Down: One Lazy Programmer

So why the hell are stacktraces upside down?

Here's why: language and runtime authors are lazy

When you’re writing the code to print a stacktrace, you’ve got to manually walk the stack. The dumbest, most obvious way looks like this:

print exception.class + ": " + exception.message
while frame = stack.pop():

This is super simple, and (very) slightly more effecient than how Python prints its stacktraces. But it wastes everybody’s time. Every programmer who touches your runtime with a terminal has to needlessly scroll, on any exception where the stack is big enough.

Of course IDEs, emacs’ clojure integration, and other exception gathering tools deal with this by showing the top of the stacktrace first. But many millions of programmers use terminals for everything, and nobody thinks about the basic usability of their error messages.

It wastes huge amounts of time for decades to come.

This is such a basic usability issue, but nobody gets it right.

Many thanks to Gary Bernhardt for first making me mad about this.

This is a blog about the development of Yeller, the Exception Tracker with Answers.

Read more about Yeller here

Looking for more about running production applications, debugging, Clojure development and distributed systems? Subscribe to our newsletter: