In his most recent (as of this writing) blog entry Brad Abrams writes about an idea we've been kicking around and which I happen to like very much.

I think though that adding a few more details is necessary to help get the best possible feedback.

The idea is that there would be conditional compilation sections in the IL itself, these sections would always be present in the IL so every machine would have the capacity to run that code.  Depending on configuration, the JIT would either compile that IL into machine code, or else ignore it.  By default, every developers box would be configured to get all the debug checks and my mom's machine would be configured to not get them.

Properties of this system if it could be made to work:

  • only one version of IL is distributed
  • any machine could be configured to run the debug code if needed because its always distributed
  • normal machines wouldn't pay the penalty for additional checks, developer machines would
  • some existing/redudant checks which exist soley to give developers better diagnostics would normally run only on developer machines
  • super-heavy-weight checks or logging which even developers wouldn't normally want to pay for could be introduced if needed
  • advanced versions of the CLR could someday recompile methods on the fly (!) by administrative order, injecting the debug or logging blocks as directed into running processes (how much would you pay for that!)
  • any number of configurable block types could ultimately be supported with the same architecture

In order to avoid problems like putting the wrong code into a debug block (similar to putting necessary functions into assert statements that are compiled away) we'd want to invest in FXCop like rules to statically evaluate the content of such blocks.  In particular “demands” would be frowned upon.

My thesis is that this feature increases developer productivity by allowing greater checking at no end-user cost and giving easy access to that checking when it is most needed while also giving a net increase in performance for the existing libraries after retrofit.  In contrast to other complexity-adding features (and make no mistake, this is a complexity addition), my mom's working set can be expected to get smaller, not bigger.

I believe in giving developers very sharp tools when warranted.  I think this is warranted.