Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #5052
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Why C++ is vastly superior to C |
| Date | 2011-05-17 11:37 +1200 |
| Message-ID | <93dqq6FlpiU14@mid.individual.net> (permalink) |
| References | <iqremk$ltg$1@dont-email.me> <93dhneFlpiU7@mid.individual.net> <4dd19427$0$2855$7b1e8fa0@news.nbl.fi> <93djkcFlpiU10@mid.individual.net> <mdn8a8-eg1.ln1@wilbur.25thandClement.com> |
On 05/17/11 11:09 AM, William Ahern wrote: > Ian Collins<ian-news@hotmail.com> wrote: >> I'm not saying it's not a lot easier to do generic containers or >> algorithms with templates. I'm saying it's impossible to do RAII in C. > >> I've often been asked by teams I've managed or coached why they should >> look at using C++ rather than C and my response normally something along >> the lines of "what's an automatic, simple means of preventing resource >> leaks worth to you?" Then we get onto the other stuff! One (DSP) team >> was happy just to use C++ as "C with RAII (and function overloading)". > > "Resource Acquisition is Initialization". The primary benefit from RAII is > ordering resource initializations so that you don't end up with an > innumerable number of failure combinations, and limiting shared ownership of > resources, preferable in a strongly hierarchical arrangement. It's not in > automatic destruction of automatic storage objects, which is comparatively > more useful in C++ than C because in C++ the exit from a routine could be > involutary given exceptions. The presence or lack of exceptions does indeed play a big part in the importance of RAII in C++. But even in their absence, automatic clean up does lead to cleaner code and more importantly, greater code reuse. By extending RAII into smart pointers, another class of dynamic resource management is abstracted away from the user - ownership. > Proper ordering of resource mangement in C also gets you the majority of > these benefits, a result not of language features but of good programming > habits. Comparing poor resource management in C with good resource > management in C++ is comparing apples to oranges. If programmers were so > inept at tracking memory anyhow, they'd be best in a GCd environment. If > they feel the impulse to allocate dynamic strings randomly where ever it > suits them, then they're begging for leaks, and really should be using a GCd > language, whether in C or C++. If they properly order allocation of these > resources, then the gap between C and C++ becomes quite small; maybe not > small enough, but perhaps for other considerations to move to the forefront. Yes good practice can also handle these issues, but at the cost of more code, more reviews and ultimately, more chance of a hapless maintenance programmer inadvertently messing the whole thin up. Don't forget memory isn't the only dynamic resource that has to be managed, so GC only goes part of the way. Which is one reason most (all?) GC'd languages end up with some form of finalise construct where all the code that sits under a goto in C ends up! > [I'll refrain from commenting on the obscene nested containers example as > I'm sure it made you cringe as well.] It did! -- Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar
Why C++ is vastly superior to C Lynn McGuire <lmc@winsim.com> - 2011-05-16 10:08 -0500
Re: Why C++ is vastly superior to C "crea" <no@invalid.com> - 2011-05-16 16:13 +0100
Re: Why C++ is vastly superior to C "Balog Pal" <pasa@lib.hu> - 2011-05-16 17:26 +0200
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-16 21:21 +0100
Re: Why C++ is vastly superior to C Ian Collins <ian-news@hotmail.com> - 2011-05-17 08:57 +1200
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-18 00:12 +0100
Re: Why C++ is vastly superior to C Krice <paulkp@mbnet.fi> - 2011-05-16 09:29 -0700
Re: Why C++ is vastly superior to C Leigh Johnston <leigh@i42.co.uk> - 2011-05-16 17:37 +0100
Re: Why C++ is vastly superior to C Öö Tiib <ootiib@hot.ee> - 2011-05-16 10:51 -0700
Re: Why C++ is vastly superior to C Keith H Duggar <duggar@alum.mit.edu> - 2011-05-17 06:12 -0700
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-17 14:12 +0000
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 00:30 -0500
Re: Why C++ is vastly superior to C Keith H Duggar <duggar@alum.mit.edu> - 2011-05-21 11:19 -0700
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 23:41 -0500
Re: Why C++ is vastly superior to C Paavo Helde <myfirstname@osa.pri.ee> - 2011-05-23 00:41 -0500
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-23 01:02 -0500
Re: Why C++ is vastly superior to C Keith H Duggar <duggar@alum.mit.edu> - 2011-05-23 06:10 -0700
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-24 01:01 -0500
Re: Why C++ is vastly superior to C Keith H Duggar <duggar@alum.mit.edu> - 2011-05-23 05:59 -0700
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-16 17:24 +0000
Re: Why C++ is vastly superior to C Lynn McGuire <lmc@winsim.com> - 2011-05-16 12:36 -0500
Re: Why C++ is vastly superior to C Krice <paulkp@mbnet.fi> - 2011-05-16 11:25 -0700
Re: Why C++ is vastly superior to C "Balog Pal" <pasa@lib.hu> - 2011-05-16 21:16 +0200
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-16 21:11 +0100
Re: Why C++ is vastly superior to C Krice <paulkp@mbnet.fi> - 2011-05-16 14:12 -0700
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-17 00:48 +0100
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-20 23:36 -0500
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-21 12:25 +0100
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 08:22 -0500
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-16 21:00 +0000
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-20 23:33 -0500
Re: Why C++ is vastly superior to C Nobody <nobody@nowhere.com> - 2011-05-16 18:53 +0100
Re: Why C++ is vastly superior to C Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-16 12:05 -0700
Re: Why C++ is vastly superior to C Ian Collins <ian-news@hotmail.com> - 2011-05-17 11:09 +1200
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-20 23:58 -0500
Re: Why C++ is vastly superior to C "Balog Pal" <pasa@lib.hu> - 2011-05-17 01:23 +0200
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-17 00:47 +0100
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-17 07:34 +0000
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-17 11:55 +0100
Re: Why C++ is vastly superior to C Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-16 16:30 -0700
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-17 00:46 +0100
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-17 01:10 +0100
Re: Why C++ is vastly superior to C Öö Tiib <ootiib@hot.ee> - 2011-05-17 11:12 -0700
Re: Why C++ is vastly superior to C Gert-Jan de Vos <gert-jan.de.vos@onsneteindhoven.nl> - 2011-05-17 14:30 -0700
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-18 16:37 +0000
Re: Why C++ is vastly superior to C Lynn McGuire <lmc@winsim.com> - 2011-05-18 12:04 -0500
Re: Why C++ is vastly superior to C yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-05-20 10:11 +0000
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 00:21 -0500
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-21 08:20 +0000
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 08:33 -0500
Re: Why C++ is vastly superior to C yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-05-23 13:32 +0000
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-24 00:36 -0500
Re: Why C++ is vastly superior to C yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-05-24 12:26 +0000
Re: Why C++ is vastly superior to C Nobody <nobody@nowhere.com> - 2011-05-21 18:27 +0100
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-21 18:43 +0000
Re: Why C++ is vastly superior to C Dombo <dombo@disposable.invalid> - 2011-05-21 21:10 +0200
Re: Why C++ is vastly superior to C "Balog Pal" <pasa@lib.hu> - 2011-05-21 21:48 +0200
Re: Why C++ is vastly superior to C Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-05-21 22:18 +0200
Re: Why C++ is vastly superior to C "Balog Pal" <pasa@lib.hu> - 2011-05-22 02:31 +0200
Re: Why C++ is vastly superior to C Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-05-22 11:54 +0200
Re: Why C++ is vastly superior to C "Balog Pal" <pasa@lib.hu> - 2011-05-22 12:23 +0200
Re: Why C++ is vastly superior to C Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-05-22 14:22 +0200
Re: Why C++ is vastly superior to C "Balog Pal" <pasa@lib.hu> - 2011-05-23 12:01 +0200
Re: Why C++ is vastly superior to C Dombo <dombo@disposable.invalid> - 2011-05-21 22:45 +0200
Re: Why C++ is vastly superior to C Ian Collins <ian-news@hotmail.com> - 2011-05-22 08:56 +1200
Re: Why C++ is vastly superior to C Öö Tiib <ootiib@hot.ee> - 2011-05-21 16:08 -0700
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-22 13:39 +0100
Re: Why C++ is vastly superior to C "Balog Pal" <pasa@lib.hu> - 2011-05-22 02:59 +0200
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-22 13:24 +0100
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 00:12 -0500
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-18 00:10 +0100
Re: Why C++ is vastly superior to C Öö Tiib <ootiib@hot.ee> - 2011-05-18 02:38 -0700
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 00:03 -0500
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-21 12:21 +0100
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 08:38 -0500
Re: Why C++ is vastly superior to C Nobody <nobody@nowhere.com> - 2011-05-17 06:37 +0100
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 00:28 -0500
Re: Why C++ is vastly superior to C Isaac Gouy <igouy2@yahoo.com> - 2011-05-17 08:33 -0700
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-20 23:43 -0500
Re: Why C++ is vastly superior to C Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-21 00:47 -0700
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 08:41 -0500
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-21 08:22 +0000
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 08:44 -0500
Re: Why C++ is vastly superior to C "Balog Pal" <pasa@lib.hu> - 2011-05-21 18:34 +0200
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 23:37 -0500
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-22 05:57 +0000
Re: Why C++ is vastly superior to C Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-22 01:22 -0700
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-24 15:54 +0000
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-24 15:58 +0000
Re: Why C++ is vastly superior to C Leigh Johnston <leigh@i42.co.uk> - 2011-05-24 17:19 +0100
Re: Why C++ is vastly superior to C Leigh Johnston <leigh@i42.co.uk> - 2011-05-25 14:09 +0100
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-25 15:00 +0100
Re: Why C++ is vastly superior to C gwowen <gwowen@gmail.com> - 2011-05-25 07:20 -0700
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-24 17:42 +0100
Re: Why C++ is vastly superior to C hanukas <jukka@liimatta.org> - 2011-05-24 23:38 -0700
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-25 11:15 +0100
Re: Why C++ is vastly superior to C jacob navia <jacob@spamsink.net> - 2011-05-25 13:07 +0200
Re: Why C++ is vastly superior to C gwowen <gwowen@gmail.com> - 2011-05-25 05:12 -0700
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-25 15:31 +0100
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-20 23:49 -0500
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-20 23:31 -0500
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-16 17:25 +0000
Re: Why C++ is vastly superior to C Ebenezer <woodbrian77@gmail.com> - 2011-05-16 13:01 -0700
Re: Why C++ is vastly superior to C Ian Collins <ian-news@hotmail.com> - 2011-05-17 09:02 +1200
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-16 21:16 +0000
Re: Why C++ is vastly superior to C Ian Collins <ian-news@hotmail.com> - 2011-05-17 09:35 +1200
Re: Why C++ is vastly superior to C Lynn McGuire <lmc@winsim.com> - 2011-05-16 17:11 -0500
Re: Why C++ is vastly superior to C William Ahern <william@wilbur.25thandClement.com> - 2011-05-16 16:09 -0700
Re: Why C++ is vastly superior to C Ian Collins <ian-news@hotmail.com> - 2011-05-17 11:37 +1200
Re: Why C++ is vastly superior to C Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-16 16:45 -0700
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-17 08:20 +0000
Re: Why C++ is vastly superior to C Paul Brettschneider <paul.brettschneider@yahoo.fr> - 2011-05-17 15:43 +0200
Re: Why C++ is vastly superior to C Pete Becker <pete@versatilecoding.com> - 2011-05-17 09:59 -0400
Re: Why C++ is vastly superior to C Keith H Duggar <duggar@alum.mit.edu> - 2011-05-17 07:09 -0700
Re: Why C++ is vastly superior to C Keith H Duggar <duggar@alum.mit.edu> - 2011-05-17 07:14 -0700
Re: Why C++ is vastly superior to C "Balog Pal" <pasa@lib.hu> - 2011-05-17 16:59 +0200
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 01:06 -0500
Re: Why C++ is vastly superior to C Paul Brettschneider <paul.brettschneider@yahoo.fr> - 2011-05-17 16:31 +0200
Re: Why C++ is vastly superior to C "Balog Pal" <pasa@lib.hu> - 2011-05-17 16:55 +0200
Re: Why C++ is vastly superior to C yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-05-17 13:45 +0000
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-17 14:18 +0000
Re: Why C++ is vastly superior to C Ian Collins <ian-news@hotmail.com> - 2011-05-17 11:12 +1200
Re: Why C++ is vastly superior to C Nobody <nobody@nowhere.com> - 2011-05-17 06:46 +0100
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 01:14 -0500
Re: Why C++ is vastly superior to C Nobody <nobody@nowhere.com> - 2011-05-21 09:09 +0100
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 08:46 -0500
Re: Why C++ is vastly superior to C Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-21 01:14 -0700
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 08:57 -0500
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 23:48 -0500
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-21 08:25 +0000
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 09:08 -0500
Re: Why C++ is vastly superior to C Dombo <dombo@disposable.invalid> - 2011-05-21 18:43 +0200
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 23:55 -0500
Re: Why C++ is vastly superior to C Dombo <dombo@disposable.invalid> - 2011-05-22 21:58 +0200
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-22 23:10 -0500
Re: Why C++ is vastly superior to C Ian Collins <ian-news@hotmail.com> - 2011-05-23 16:14 +1200
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-22 23:38 -0500
Re: Why C++ is vastly superior to C Ian Collins <ian-news@hotmail.com> - 2011-05-23 16:41 +1200
Re: Why C++ is vastly superior to C gwowen <gwowen@gmail.com> - 2011-05-17 00:19 -0700
Re: Why C++ is vastly superior to C gwowen <gwowen@gmail.com> - 2011-05-17 07:35 -0700
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-17 16:13 +0000
Re: Why C++ is vastly superior to C Juha Nieminen <nospam@thanks.invalid> - 2011-05-17 08:26 +0000
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 01:18 -0500
Re: Why C++ is vastly superior to C Man-wai Chang <toylet.toylet@gmail.com> - 2011-05-18 15:38 +0800
Re: Why C++ is vastly superior to C Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-18 01:27 -0700
Re: Why C++ is vastly superior to C jacob navia <jacob@spamsink.net> - 2011-05-18 19:55 +0200
Re: Why C++ is vastly superior to C Miles Bader <miles@gnu.org> - 2011-05-19 13:50 +0900
Re: Why C++ is vastly superior to C Krice <paulkp@mbnet.fi> - 2011-05-20 02:46 -0700
Re: Why C++ is vastly superior to C gwowen <gwowen@gmail.com> - 2011-05-20 03:49 -0700
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 01:25 -0500
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-21 12:08 +0100
Re: Why C++ is vastly superior to C "MikeP" <mp011011@some.org> - 2011-05-21 09:19 -0500
Re: Why C++ is vastly superior to C Michael Tsang <miklcct@gmail.com> - 2011-05-19 20:26 +0800
Re: Why C++ is vastly superior to C Rui Maciel <rui.maciel@gmail.com> - 2011-05-20 13:28 +0100
Re: Why a skyscraper is vastly superior to a home jacob navia <jacob@spamsink.net> - 2011-05-23 22:18 +0200
Re: Why a skyscraper is vastly superior to a home "MikeP" <mp011011@some.org> - 2011-05-24 01:23 -0500
Re: Why a skyscraper is vastly superior to a home "MikeP" <mp011011@some.org> - 2011-05-24 01:30 -0500
Re: Why a skyscraper is vastly superior to a home gwowen <gwowen@gmail.com> - 2011-05-24 00:44 -0700
csiph-web