Why Exceptions Are Just Sophisticated Gotos - and How to Move Beyond

Florian Wilhelm

Wednesday 12:25 in Titanium3

Exceptions have long been seen as an improvement over error-handling approaches like goto. However, they can introduce complexity and obscure control flow when used without care. This talk will critically examine exceptions, outline the similarities to goto, and explore better ways to handle errors in programming.

Outline:

  1. Introduction (5 minutes)
    • The historical role of goto in programming.
    • Spaghetti code and the rise of structured programming.
    • How exceptions emerged as an alternative.
  2. Why and What Are Exceptions (10 minutes)
    • Why exceptions were introduced.
    • How they became mainstream in languages like Java and C++.
    • Common problems caused by exceptions: hidden control flow, debugging challenges, and performance impacts.
  3. The Evolution Toward Result Types (10 minutes)
    • How result types address the shortcomings of exceptions.
    • Implementations in Haskell, Rust, and Golang.
    • Real-world benefits of using result types.
  4. Using Result Types in Python (10 minutes)
    • Introducing the returns package.
    • Practical examples of result types in Python.
    • How this approach improves code clarity and reliability.
  5. Conclusion (5 minutes)
    • Recap of the journey from goto to exceptions to result types.
    • Key takeaways: thoughtful error handling and modern best practices.
    • Encouragement to explore and adopt better patterns in Python.

This session is ideal for intermediate and advanced Python developers seeking actionable techniques to improve error handling and write cleaner, more predictable code.

Florian Wilhelm

Florian is Head of Data Science & Mathematical Modeling at inovex GmbH, an IT project center driven by innovation and quality, focusing its services on ‘Digital Transformation’. He holds a PhD in mathematics, has more than 10 years of experience in predictive & prescriptive analytics use-cases and likes everything math 🤯