Error Messaging with Programming Languages

Recently I had the misfortune of working on a project in VBA meaning I also had the misfortune of dealing with the useless Microsoft error messaging system (see the ever so helpful “Object required” message, followed by it’s close friend the “Object variable or With block variable not set” message). Furthermore, I’ve also had the far more pleasurable experience of working with Clojure recently. However, Clojure, too, is plagued by poor error messaging. Which had me thinking, what are some of the ways error messaging ought to be handled with different languages? Here’s the list I came up with:

  1. Stack trace. Debugging in VBA is a complete pain in the ass without a complete stack of where your code screwed up in. Java does this perfectly, as well as Clojure. Stack tracing lets a developer see where exactly the error originated from and what it affects allowing for faster debugging than inserting a truckload of break points.
  2. Short and concise. There’s no point in having elaborate, five-liners of the problem (as is sometimes the case in Clojure). State the problem, point to a few useful lines and let the developer do what the developer does best. Making it any longer than needed means unnecessary complexity requiring additional brain power to process. This brain power could better be spent fixing the issue at hand.
  3. Human comprehensible. Making it short and concise (a la VBA) does not mean the error message need make no sense whatsoever. The message should still have enough descriptive power for, at least, an average user to understand what it is that the error may have been triggered by. At the end of the day the error message is supposed to help a developer, not leave them bashing their heads against a keyboard or repeatedly going to the same stackoverflow thread in hopes of an epiphany. Ideally the messaging ought be easy enough to comprehend that even new learners of the language would be able to get a sense of what is going on.
  4. Offers next steps if relevant. This is just a personal preference, but I do recognize that it is impossible or, at the very least difficult, to implement for some general errors or commonly used features in a language. That being said, it would be immensely helpful if, after coming across as rare error that you have never seen before, you are pointed in the direction of how to fix it, e.g. via a link to a website detailing the error more specifically and troubleshooting steps (but please NOT like the awfully generic and poor documented ones on MSDN).

Error messaging ought to be simple and helpful for the user. Programmers are humans too, and it’s a lot simpler to see something along the lines of “You did not initialize the variable [NAME]” versus “Object required” or some junk like that. That being said, as much as I said Clojure has poor error messaging, there have been efforts in recent revisions to improve that and I do believe that we shall soon have a more accessible programming language in our hands.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s