Linked by Thom Holwerda on Mon 13th Aug 2007 17:57 UTC
General Development "A good programming language is far more than a simple collection of features. My ideal is to provide a set of facilities that smoothly work together to support design and programming styles of a generality beyond my imagination. Here, I briefly outline rules of thumb (guidelines, principles) that are being applied in the design of C++0x. Then, I present the state of the standards process (we are aiming for C++09) and give examples of a few of the proposals such as concepts, generalized initialization, being considered in the ISO C++ standards committee. Since there are far more proposals than could be presented in an hour, I'll take questions." Dr. Bjarne Stroustrup is the original designer and implementer of the C++ Programming Language.
Thread beginning with comment 263259
To read all comments associated with this story, please click here.
C++ horrors
by CrazyDude0 on Tue 14th Aug 2007 01:59 UTC
CrazyDude0
Member since:
2005-07-10

I would call myself fairly C++ knowledgeable and i use it often for user mode programming. But once i had to debug someone else's code written in C++ and following were my horrors:

1. templates inside templates inside templates....Nested templates are the worst thing designed in C++
2. Operator overloading - While looking at the code, i really did not know whether a + is a function call that can throw or it is a simple addition.
3. Exception handling - It just makes large project so much harder to debug because you never know once an internal function throw, where the exception will get caught. And the handler that catches the exception usually doesn't have any idea on what to do with it.
4. smart pointer type stuff - C++ doesn't have garbage collection and people shouldn't try to mimic that. With all the auto_ptr crap associated with nested templates, finding where and when an object leaks was a nightmare.

After this C++ experience, i became quite anit-complex-C++. I like some of the features it provides like data abstraction using classes etc but it is becoming increasingly complex.

For myself i only use following C++ features:
1. Basic C features
2. Classes
3. Derived classes with single inheritance or multiple inheritance rarely
4. Well design STL type templates
5. Virtual function where appropriate but not very often

The things i avoid like anything are:
1. Nested Templates (and in general all templates except STL)
2. Exception handling - I hate compiler unwinding the call stack etc. It is so much harder to debug.
3. auto_ptr style memory management - It is never right and when it is wrong, it is nightmare to maintain.
4. Operator overloading - I avoid it mostly but i know for some math related tasks it is nice. Use with caution...don't overdo it. One person overloaded operator >> for sending data on socket and that is too much for me.
5. Crap stuff like virtual constructor etc etc and all the *extra smart* C++ receipes available in some books.

And yeah, if you really want to know how twisted C++ can be, read Effective C++ series. After reading that i realized how complex C++ can get and how to never get in that trap.

Edited 2007-08-14 02:03

RE: C++ horrors
by pauls101 on Tue 14th Aug 2007 15:47 in reply to "C++ horrors"
pauls101 Member since:
2005-07-07

The things i avoid like anything are:
1. Nested Templates (and in general all templates except STL)
2. Exception handling .... It is so much harder to debug.
3. auto_ptr style memory management - It is never right and when it is wrong, it is nightmare to maintain.
4. Operator overloading - I avoid it mostly .... Use with caution...don't overdo it. ...
5. Crap stuff like virtual constructor etc etc and all the *extra smart* C++ receipes ...
And yeah, if you really want to know how twisted C++ can be, read Effective C++ series.


Nice to see that someone agrees with me... I've been saying this for years, taking the flames. If you need/want a more powerful language than C++, go for it but don't complain when you can't twiddle bits fast or access your system as easily.

Why is it better to write 5 lines of code instead of 25, if:
- it can't be read or maintained even by me
- portability is shaky
- if it doesn't compile, it's easier to switch to the 25 line version than figure out why
- if it doesn't work, it really can't be debugged
- it takes just as long to write and longer to compile.

I do use templates, but I don't nest them; I throw exceptions, but very rarely out of a function; I'm leery of auto_ptr-type things I didn't write; and banning boost from production code was worth it for the saved research time alone.

I call this method "Aim low and SHIP!" and it's served several companies (and me) very well.

Reply Parent Bookmark Score: 1