4 ms·
This is a common dogma in .net land. If we're being fair a more accurate statement would be "you currently get a performance penalty when you throw exceptions i
by benjiweber 15y ago
This is a common dogma in .net land. If we're being fair a more accurate statement would be "you currently get a performance penalty when you throw exceptions in Microsoft's implementation of .net".
Exceptions are much faster in mono than Microsoft's .net[0], are much faster still in Java[0] and can be made as fast as goto in Java in some circumstances[1], particularly if you control the Exception class being thrown.
Claiming Exceptions are slow is like saying "Java is slow". Languages and language features aren't slow, implementations are.
[0] http://weblog.ikvm.net/PermaLink.aspx?guid=388b2a6d-e7b2-4ffa-86e7-450c87e6178f http://weblog.ikvm.net/PermaLink.aspx?guid=388b2a6d-e7b2-4ff...
[1] http://blogs.oracle.com/jrose/entry/longjumps_considered_inexpensive http://blogs.oracle.com/jrose/entry/longjumps_considered_ine...
- thepumpkin1979 15y agoThese are very interesting articles benjiweber and you are right, it depends of the implementation. My point is that there are some cases in which you can gain some speed by no throwing exceptions at all and TryParse is a perfect example of this(at least in .NET). Also exception-handling blocks might prevent the Virtual Machine from inlining the method(again, at least in .NET), is this true for the JVM too?