Exception-Driven Development Gives You Back Your Time and Sanity

3 min read Original article ↗

Hello, friends!

I’ve been doing software development professionally for a few years now, and I’m noticing a trend in newer languages that I’m really liking: putting errors front and center.

This is a very welcome development that benefits developers everywhere. Take it from someone who has developed web apps professionally using vanilla JavaScript! The languages seems almost eager to trick you into doing silly things like using double-equals instead of triple-equals.

This is because JavaScript’s design philosophy wants to avoid crashing under almost any circumstances, even if data ends up being corrupted due to silent, sneaky errors later on. This can be a real pain for devs, as debugging is a huge part of the job. The deadly combo of a wonky type system and a language that doesn’t emphasize handling or acknowledging errors when they come up can lead to some serious headaches and wasted time!

You can compensate for these faults of JavaScript by being super vigilant about types, unit testing, and other such practices. The problem is that this leads to a lot of extra mental load, because the language passed the buck to the developer. Slow feedback loops on new code, since the reviewer needs to be as or more defensive than the original author, and missed corner cases are also a big risk with dynamically typed languages.

Enter Go and Rust. These newer languages have smaller ecosystems than more established players like Java, C# and JavaScript/TypeScript, but their design places high importance on handling errors as they come up. In Go land, the if err != nil pattern is the cause of much hand-wringing, but I can tell you that trying to manually reason about and remember error conditions in your code leads to much more pain in short order. Even worse if you have to look at the docs just to know that something can return an error at all!

One can argue that CI/CD can also catch many such errors and code smells, but that stuff costs much more time and money to run than the Go or Rust compiler.

interestingly, the newer typed languages (I hesitate to call Go strongly-typed compared to TypeScript or even Java) can sometimes even beat dynamically-typed languages at their own game. Errors can be handled simply by logging them, so you can iterate quickly while still having types and strictness around errors!

if you enjoy reading my posts, please subscribe to this blog by entering your email. 🙂

Make a one-time donation

Like my work? Consider donating!

Custom donation amount:


Your contribution is appreciated.

Donate