Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.arch.embedded > #18678
| From | Tauno Voipio <tauno.voipio@notused.fi.invalid> |
|---|---|
| Newsgroups | comp.arch.embedded |
| Subject | Re: reasons for preferring C over C++ |
| Date | 2014-10-16 10:34 +0300 |
| Organization | A noiseless patient Spider |
| Message-ID | <m1nsdu$25d$1@dont-email.me> (permalink) |
| References | <543ead04$0$15847$e4fe514c@dreader35.news.xs4all.nl> <m1mkfl$s4a$1@dont-email.me> <543ee88f$0$6850$e4fe514c@dreader36.news.xs4all.nl> |
On 16.10.14 00:35, Wouter van Ooijen wrote: > David Brown schreef op 15-Oct-14 10:12 PM: >> On 15/10/14 19:21, Wouter van Ooijen wrote: >>> "Small-chip programmers are better off using C++ instead of C." >>> >>> Take small-chip as =<256 Kb Flash and <32 kB RAM, down to the smallest >>> micro-controller you can think of. >>> >>> A student of me is looking for reasons that are put forward for >>> preferring C over C++ on small chips. (Note: all reasons, not just >>> *valid* reasons). >>> >>> So far he found >>> >>> - tooling & experience (no C++ available for my chip, no C++ experience) >>> >> >> I'd split that into two reasons, as they are very different issues. > > True. I lumped them together because the both have nothing to do with > the language itself. Availablility of libraries (other than the standrad > libraries) could be added here. > >> >>> - semantic distance to the machine code (I can't easily see what code >>> this C++ construct will cause) >>> >>> - C++ stronger typing gets in the way (forces you to write lots of >>> casts) >>> >>> - the const trap (ultimately you might/will need to cast the cost away) >>> >>> - errors are harder to locate >>> >>> Can you suggest more reasons, or sources (pages, articles, books, etc) >>> that mention such reason? >>> >>> PS I am (in the context of this question) NOT interested in >>> >>> - purely emotionally rants (like: C++ sucks, C rocks) >>> >>> - whether a reason is valid (please start a different thread for >>> discussing this, I'll surely join in). >>> >>> Wouter van Ooijen >> >> >> (Before anyone replies here, remember what Wouter asked for - reasons >> without regard to validity! Some of these here are commonly-believed >> FUD.) >> >> >> How about: >> >> C lets you write spaghetti code which is hard to understand, C++ lets >> you write lasagne code which is even worse. >> >> Exceptions are just undocumented gotos. >> >> All other embedded code, such as RTOS's or network stacks, is written in >> C - so you can't work in pure C++. >> >> Templates cause code bloat. >> >> The STL causes code bloat. >> >> Objects in C++ use the heap, and dynamic memory on a small system is bad. >> >> Objects means everything involves at least one pointer (*this), which is >> inefficient on small cpus. >> >> Templates make code unreadable and undebuggable. >> >> You can't use advanced C features, such as VLA's and designated >> initialisers, in C++. >> >> Coding standards insist on ANSI C. >> >> Some quotations from Bjarne Stroustrup might help too >> (<http://en.wikiquote.org/wiki/Bjarne_Stroustrup>) : >> >> Within C++, there is a much smaller and cleaner language struggling to >> get out. >> >> C makes it easy to shoot yourself in the foot; C++ makes it harder, but >> when you do it blows your whole leg off. >> > > I think you fully understand what I am asking for! Although some of your > quotes fall under "purely emotionally rants", they still represent > reasons for some persons not to use C++. I strust my student will have > plenty of material. There are exceptionally good responses. I'd like to add that a serious programmer for small chips must read and understand the generated assembly code, to avoid nasty surprises. (I've had enough of them during 50 years of coding ...) -- Tauno Voipio
Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
reasons for preferring C over C++ Wouter van Ooijen <wouter@voti.nl> - 2014-10-15 19:21 +0200
Re: reasons for preferring C over C++ Paul Rubin <no.email@nospam.invalid> - 2014-10-15 10:36 -0700
Re: reasons for preferring C over C++ Wouter van Ooijen <wouter@voti.nl> - 2014-10-15 19:48 +0200
Re: reasons for preferring C over C++ Tom Gardner <spamjunk@blueyonder.co.uk> - 2014-10-15 21:25 +0100
Re: reasons for preferring C over C++ Wouter van Ooijen <wouter@voti.nl> - 2014-10-15 23:28 +0200
Re: reasons for preferring C over C++ Tom Gardner <spamjunk@blueyonder.co.uk> - 2014-10-15 23:40 +0100
Re: reasons for preferring C over C++ Don Y <this@is.not.me.com> - 2014-10-15 10:58 -0700
Re: reasons for preferring C over C++ upsidedown@downunder.com - 2014-10-15 21:03 +0300
Re: reasons for preferring C over C++ Don Y <this@is.not.me.com> - 2014-10-15 11:11 -0700
Re: reasons for preferring C over C++ Wouter van Ooijen <wouter@voti.nl> - 2014-10-15 20:26 +0200
Re: reasons for preferring C over C++ Stefan Reuther <stefan.news@arcor.de> - 2014-10-15 20:44 +0200
Re: reasons for preferring C over C++ Wouter van Ooijen <wouter@voti.nl> - 2014-10-15 23:30 +0200
Re: reasons for preferring C over C++ Stefan Reuther <stefan.news@arcor.de> - 2014-10-16 18:19 +0200
Re: reasons for preferring C over C++ Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2014-10-16 23:12 +0200
Re: reasons for preferring C over C++ Reinhardt Behm <rbehm@hushmail.com> - 2014-10-17 13:25 +0800
Re: reasons for preferring C over C++ Stefan Reuther <stefan.news@arcor.de> - 2014-10-17 18:43 +0200
Re: reasons for preferring C over C++ "tim....." <tims_new_home@yahoo.co.uk> - 2014-10-18 12:29 +0100
Re: reasons for preferring C over C++ Paul Rubin <no.email@nospam.invalid> - 2014-10-18 11:44 -0700
Re: reasons for preferring C over C++ Tom Gardner <spamjunk@blueyonder.co.uk> - 2014-10-18 22:25 +0100
Re: reasons for preferring C over C++ Paul Rubin <no.email@nospam.invalid> - 2014-10-18 15:42 -0700
Re: reasons for preferring C over C++ Niklas Holsti <niklas.holsti@tidorum.invalid> - 2014-10-19 11:03 +0300
Re: reasons for preferring C over C++ Tim Wescott <seemywebsite@myfooter.really> - 2014-10-19 17:46 -0500
Re: reasons for preferring C over C++ Paul Rubin <no.email@nospam.invalid> - 2014-10-19 16:28 -0700
Re: reasons for preferring C over C++ Nobody <nobody@nowhere.invalid> - 2014-10-20 02:47 +0100
Re: reasons for preferring C over C++ "tim....." <tims_new_home@yahoo.co.uk> - 2014-10-19 09:34 +0100
Re: reasons for preferring C over C++ Paul Rubin <no.email@nospam.invalid> - 2014-10-19 17:00 -0700
Re: reasons for preferring C over C++ Tom Gardner <spamjunk@blueyonder.co.uk> - 2014-10-20 08:50 +0100
Re: reasons for preferring C over C++ "tim....." <tims_new_home@yahoo.co.uk> - 2014-10-20 11:57 +0100
Re: reasons for preferring C over C++ Tom Gardner <spamjunk@blueyonder.co.uk> - 2014-10-20 12:11 +0100
Re: reasons for preferring C over C++ upsidedown@downunder.com - 2014-10-20 22:36 +0300
Re: reasons for preferring C over C++ Simon Clubley <clubley@remove_me.eisner.decus.org-Earth.UFP> - 2014-10-21 00:36 +0000
Re: reasons for preferring C over C++ Tom Gardner <spamjunk@blueyonder.co.uk> - 2014-10-20 08:52 +0100
Re: reasons for preferring C over C++ "tim....." <tims_new_home@yahoo.co.uk> - 2014-10-20 11:56 +0100
Re: reasons for preferring C over C++ Stefan Reuther <stefan.news@arcor.de> - 2014-10-19 10:52 +0200
Re: reasons for preferring C over C++ Paul Rubin <no.email@nospam.invalid> - 2014-10-19 17:16 -0700
Re: reasons for preferring C over C++ glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-10-18 23:02 +0000
Re: reasons for preferring C over C++ "tim....." <tims_new_home@yahoo.co.uk> - 2014-10-19 09:45 +0100
Re: reasons for preferring C over C++ David Brown <david.brown@hesbynett.no> - 2014-10-15 22:12 +0200
Re: reasons for preferring C over C++ Wouter van Ooijen <wouter@voti.nl> - 2014-10-15 23:35 +0200
Re: reasons for preferring C over C++ Paul Rubin <no.email@nospam.invalid> - 2014-10-15 19:10 -0700
Re: reasons for preferring C over C++ Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2014-10-16 10:34 +0300
Re: reasons for preferring C over C++ Tom Gardner <spamjunk@blueyonder.co.uk> - 2014-10-16 10:10 +0100
Re: reasons for preferring C over C++ Tim Wescott <tim@seemywebsite.com> - 2014-10-16 01:06 -0500
Re: reasons for preferring C over C++ Anders.Montonen@kapsi.spam.stop.fi.invalid - 2014-10-16 08:32 +0000
Re: reasons for preferring C over C++ David Brown <david.brown@hesbynett.no> - 2014-10-16 20:54 +0200
csiph-web