Why I love C++ so much.

Igor Peshansky pechtcha@cs.nyu.edu
Fri Feb 22 16:33:00 GMT 2008


On Fri, 22 Feb 2008, Dave Korn wrote:

> On 22 February 2008 16:14, Igor Peshansky wrote:
>
> > On Fri, 22 Feb 2008, Danilo Turina wrote:
> >
> >> Corinna Vinschen wrote:
> >>> On Feb 21 05:26, Warren Young wrote:
> >>>> Corinna Vinschen wrote:
> >>>>> Really?  Show me an example which isn't much harder to understand than
> >>>>> the equivalent C code.
> >>>> template <class T>
> >>>> std::string foo(const T& x)
> >>>> {
> >>>>     std::ostringstream outs;
> >>>>     outs << x << and << maybe << other << stuff;
> >>>>     return outs.str();
> >>>> }
> >>>>
> >>>> (Aside: This looks pointlessly trivial, but it's a simplified version of
> >>>> real code in MySQL++ (http://tangentsoft.net/mysql++/).  It would just
> >>>> muddy the waters to talk about the reason MySQL++ does this.)
> >>>>
> >>>> To do that with C functions (maybe strto*() instead of printf()) you'd
> >>>> have to create a set of template specializations for every T you know
> >>>> about to call the right C function with the right arguments.  Any time
> >>>> you add to the list of supported T's, you have to add template
> >>>> specializations.
> >>>
> >>> Argh.  Using templates as an example for simplicity is somewhat daring.
> >>> Templates, liberally used, are a good way to make code unreadable.
> >>>
> >>> IMHO.
> >>>
> >>> FWIW.
> >>>
> >>> YMMV.
> >>>
> >>> YMCA.
> >
> > "Young men, no need to feel down"...  That brings back memories. :-)
>
>   Didn't bring back the memory of the word "there's", I note!

Hey, I didn't say they were *perfect* memories.

> >> C++ is like Unix, people that don't like it is because they don't
> >> understand it.
> >
> > C++ is for people who want to be able to not just shoot themselves in the
> > foot, but do it with a rocket launcher.  Unix allows one to throw a
> > grenade under their own feet.  So yes, they are very similar.
>
>   But it wasn't a rocket-launcher when I picked it up, it was a bar of
> soap, it only overloaded itself into a rocket launcher when I tried to
> wash my feet with it instead of my hands!

No, it was a rocket launcher all along.  It just happened to be an
overloaded "bar of soap" operator.  You should be careful with the type of
the operands...
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_	    pechtcha@cs.nyu.edu | igor@watson.ibm.com
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"That which is hateful to you, do not do to your neighbor.  That is the whole
Torah; the rest is commentary.  Go and study it." -- Rabbi Hillel



More information about the Cygwin-talk mailing list