Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1024579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:47:55+00:00 2026-05-16T11:47:55+00:00

In the D2 programming language, what are the performance implications of using exception handling?

  • 0

In the D2 programming language, what are the performance implications of using exception handling? In particular:

  • What if I write no exception handling code?
  • What if I do, but no exceptions are ever thrown?
  • What if I do, and exception are thrown?
  • Does exception handling cause any optimization opportunities to be missed?
  • Can exception handling be disabled like it can in many (most?) C++ implementations?

I know that almost all commercial game development studios disable exception handling in their C++ due to the performance implications and increased development time associated with correctly handling exceptions. I know D makes that latter less painful, but what about performance?

Of course, this is all probably implementation defined, so for this question, please focus on the DMD compiler.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:47:56+00:00Added an answer on May 16, 2026 at 11:47 am

    I cannot speak about D or any of its compilers, but I can tell you some about C++, Windows, and the Visual Studio compiler. This might help you understand roughly how D does things.

    First, exception handling on 32- and 64-bit machines is different. The x86 ABI (prolog/epilog, unwinding, calling convention) is more lax, so the compiler and the program itself must do more work. The x86-64 ABI is stricter and the OS plays a bigger role, making it easier for the program itself to work with exceptions. If you’re running D on Windows, then it likely uses SEH (structured exception handling) like C++ does.

    Again, all of my answers below relate to Windows, C++, and Visual Studio.

    What if I write no exception handling
    code?

    x86/x86-64: There is no cost for that method.

    What if I do, but no exceptions are
    ever thrown?

    x86: There is a cost even when exceptions aren’t thrown. Exception handling information is pushed into the TIB (thread information block) such as the initial scope and the function-specific exception handler. In order to know what objects to destruct and what handlers to search, a scope variable is maintained. This scope variable is updated as you enter try blocks and construct stack objects that have destructors.

    x86-64: Because of the stricter rules, there is no extra code (or very very minimal). This is a big advantage over x86.

    What if I do, and exception are
    thrown?

    On either x86 or x86-64, there will definitely be a hit. Exceptions should be exceptional though. Do not use them for regular control flow. Only use them to signal truly exceptional, unexpected events. Essentially, you should never have to worry about the cost of exceptions. Even if they took 2 seconds, you shouldn’t care, because they should only happen when everything is going south anyway.

    With that said, throwing exceptions on x86-64 is more expensive than throwing them on x86. The x86-64 architecture is optimized around the case of no exceptions being thrown, which, ideally, is nearly all the time.


    Big picture:

    • I can’t see propagating error codes being materially faster than exception handling, especially on x64 platforms.
    • I doubt you will ever find exception handling being a problem unless you’re abusing exceptions.
    • If you’re unsure, you should measure the performance of your code.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have you ever thought about the implications of this change in the Java Programming
I'm interested in using a statistical programming language within a web site I'm building
I just read the whole documentation of Templates in the D programming language but
My primary language is PHP, but I have done some (not very much) programming
Programming language: Java Ok, so I want to have a BufferedImage that keeps rotating
Programming language books usually explain that value types are created on the stack, and
Which programming language would you recommend to learn about data structures and algorithms in?
My programming language is C# .Net 3.5 and I may have to install my
In any sane programming language, from C to Javascript, an expression such as a
In THE Java™ Programming Language, Fourth Edition By Ken Arnold, James Gosling, David Holmes,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.