[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: C++ exceptions
From:       Jozef Kosoru <zyzstar () uid0 ! sk>
Date:       2005-12-20 14:48:24
Message-ID: 20051220144824.GB10813 () osiris ! uid0 ! sk
[Download RAW message or body]

On Sat, Dec 17, 2005 at 22:34:15 +0000, Frans Englich wrote:
> > > [...]
> > > I read about exceptions and like to use them in my KDE app to, but
> > > first I'd like to hear the primary reasons why KDE didn't like
> > > exceptions.
> >
> > Because C++ exceptions are evil. They were a stupid design decision
> > that wasn't thought out and not actually implemented until many
> > years after their conception.

Wake up. Exceptions were a great invention and that's why all modern
programming languages implement them.

> > They are as a result impossible to support for compilers without
> > serious trade-offs in either space or speed. (either 20% slower or
> > the need to included debug-info to unwind. Compiling with exceptions
> > does the same as using -g1)

20% slower? Ehm, yes.. if you use exceptions as a general mechanism how
to return various types from functions then you are perhaps right.

> > The short lesson in every C++ book except Stroustrups is: Don't use
> > them!
> 
> ..if the performance difference turns out to be significant.

Exactly. And moreover; complex programs without exceptions might be
slower because of addition code complexity required for non-trivial
error handling.
 
> Here's my advice: use exceptions where they design-wise make sense. If
> actual numbers(profiling) shows that exceptions is The performance
> bottle neck, first then go make the code less readable and
> unmaintainable.

And usually it's much harder to implement some non-local algorithm
optimizations if the code is less readable. A clean and efficient design
can increase the execution speed and decrease the memory footprint much
more in comparison to the small exception overhead.

Jozef

-- 
jozef kosoru
http://zyzstar.kosoru.com
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic