EmbeddedRelated.com
Forums
The 2026 Embedded Online Conference

validity of ... reasons for preferring C over C++

Started by Nobody October 16, 2014
On 17/10/14 10:43, Arlet Ottens wrote:
> On 10/17/2014 11:35 AM, Paul Rubin wrote: >> David Brown <david.brown@hesbynett.no> writes: >>> I disagree, in the embedded world. In PC programming, I agree - very >>> often you are better with a language like Python than with C or C++. >> >> I have to think that even in MCU programming there have to be better >> alternatives to C or C++. Ada seems like a possibility except that the >> toolchains are either obscure or very expensive. There have been some C > > I don't know. I think Ada only helps protect against some superficial mistakes. It does nothing to prevent someone from using a poor overall design or conceptual errors that may be much harder to catch.
That's unhelpful. Nothing can protect against conceptual errors or poor design. In the absence of anything better, I'll gratefully accept any help in avoiding errors. Apart from that, I wouldn't class some of the problems in C (let alone C++) as being "superficial". The problems that appear can be very subtle, deep-seated, difficult to detect and, most importantly, effectively impossible to ensure they aren't lurking in the code.
On 17/10/14 11:44, David Brown wrote:
> On 17/10/14 11:35, Paul Rubin wrote: >> David Brown <david.brown@hesbynett.no> writes: >>> I disagree, in the embedded world. In PC programming, I agree - very >>> often you are better with a language like Python than with C or C++. >> >> I have to think that even in MCU programming there have to be better >> alternatives to C or C++. Ada seems like a possibility except that the >> toolchains are either obscure or very expensive. There have been some C >> dialects like Cyclone that were clever but never got traction. And I >> guess there are some specialty EDSL's like Atom that aren't so good for >> general purpose development. Forth is interesting but it's from a >> different world, and still unsafe though with fewer traps than C. >> > > In theory, one could do much better than C or C++ - but not in practice. > For some systems, Ada is a possible choice. But while Ada is "safer" > than C in some ways, it has its own problems - and the limited choice of > tools, and limited number of users, mean that it is only appropriate in > certain niches. This applies even more so to other language choices, > such as Eiffel.
Yes :( The tyranny of the majority :(
On 10/17/2014 01:12 PM, Tom Gardner wrote:

>> I don't know. I think Ada only helps protect against some superficial >> mistakes. It does nothing to prevent someone from using a poor overall >> design or conceptual errors that may be much harder to catch. > > That's unhelpful. Nothing can protect against conceptual errors or > poor design. In the absence of anything better, I'll gratefully > accept any help in avoiding errors.
Sure, as long as it doesn't get in the way and doesn't have other disadvantages. In the case of Ada, there is a problem with availability of good tools and libraries, and there aren't as many users.
> Apart from that, I wouldn't class some of the problems in C > (let alone C++) as being "superficial". The problems that appear > can be very subtle, deep-seated, difficult to detect and, most > importantly, effectively impossible to ensure they aren't lurking > in the code.
Can you give an example of such a problem (that another language would prevent) ?
On 17/10/14 12:25, Arlet Ottens wrote:
> On 10/17/2014 01:12 PM, Tom Gardner wrote: > >>> I don't know. I think Ada only helps protect against some superficial >>> mistakes. It does nothing to prevent someone from using a poor overall >>> design or conceptual errors that may be much harder to catch. >> >> That's unhelpful. Nothing can protect against conceptual errors or >> poor design. In the absence of anything better, I'll gratefully >> accept any help in avoiding errors. > > Sure, as long as it doesn't get in the way and doesn't have other disadvantages. In the case of Ada, there is a problem with availability of good tools and libraries, and there aren't as many users. > >> Apart from that, I wouldn't class some of the problems in C >> (let alone C++) as being "superficial". The problems that appear >> can be very subtle, deep-seated, difficult to detect and, most >> importantly, effectively impossible to ensure they aren't lurking >> in the code. > > Can you give an example of such a problem (that another language would prevent) ?
Google is your friend :) Start with aliasing, consider libraries and applications using different compilers and optimisation settings, Nick MacLaren's "Objects Diatribe". Etc.
On 17/10/14 13:06, Tom Gardner wrote:
> On 17/10/14 10:19, David Brown wrote:
>> In PC programming, I agree - very >> often you are better with a language like Python than with C or C++. > > Agreed, but I'd like to have a good reason to take a hard look at Lua. >
One good reason is that it is relatively easy to integrate Lua into a C program, even an embedded system. I managed it a number of years ago, even though I know little of Lua (it's high on my "things to learn when I get the time" list).
On 2014-10-17 Tom Gardner wrote in comp.arch.embedded:
> > I've forgotten the name for the generic phenomenon that the ignorant > think they are better than they actually are. If anyone > can come up with a decent way of allowing people to realise what > they don't know, then they have probably found a way of making > themselves very famous, rich, and winning all sorts of prizes.
Ignorance is Bliss? Just remembered a good articile on the subject: http://www.nytimes.com/2000/01/18/health/among-the-inept-researchers-discover-ignorance-is-bliss.html -- Stef (remove caps, dashes and .invalid from e-mail address to reply by mail) Every time you manage to close the door on Reality, it comes in through the window.
On 17/10/14 13:12, David Brown wrote:
> On 17/10/14 13:06, Tom Gardner wrote: >> On 17/10/14 10:19, David Brown wrote: > >>> In PC programming, I agree - very >>> often you are better with a language like Python than with C or C++. >> >> Agreed, but I'd like to have a good reason to take a hard look at Lua. >> > > One good reason is that it is relatively easy to integrate Lua into a C > program, even an embedded system. I managed it a number of years ago, > even though I know little of Lua (it's high on my "things to learn when > I get the time" list).
Just so. It might turn out to be a reasonable way of avoiding some, but not all, of the disadvantages of myScrottyLittleDSL (TM). But that's a separate discussion!
On 10/17/2014 02:13 PM, Stef wrote:
> On 2014-10-17 Tom Gardner wrote in comp.arch.embedded: >> >> I've forgotten the name for the generic phenomenon that the ignorant >> think they are better than they actually are. If anyone >> can come up with a decent way of allowing people to realise what >> they don't know, then they have probably found a way of making >> themselves very famous, rich, and winning all sorts of prizes. > > Ignorance is Bliss? > > Just remembered a good articile on the subject: > http://www.nytimes.com/2000/01/18/health/among-the-inept-researchers-discover-ignorance-is-bliss.html >
Dunning-Kruger effect.
On 17/10/14 13:35, Arlet Ottens wrote:
> On 10/17/2014 02:13 PM, Stef wrote: >> On 2014-10-17 Tom Gardner wrote in comp.arch.embedded: >>> >>> I've forgotten the name for the generic phenomenon that the ignorant >>> think they are better than they actually are. If anyone >>> can come up with a decent way of allowing people to realise what >>> they don't know, then they have probably found a way of making >>> themselves very famous, rich, and winning all sorts of prizes. >> >> Ignorance is Bliss? >> >> Just remembered a good articile on the subject: >> http://www.nytimes.com/2000/01/18/health/among-the-inept-researchers-discover-ignorance-is-bliss.html >> > > Dunning-Kruger effect.
I award you one jelly baby ;} The effect is a real, serious problem for the "don't do something unless you understand it" type of argument.
Stef schreef op 17-Oct-14 2:13 PM:
> On 2014-10-17 Tom Gardner wrote in comp.arch.embedded: >> >> I've forgotten the name for the generic phenomenon that the ignorant >> think they are better than they actually are. If anyone >> can come up with a decent way of allowing people to realise what >> they don't know, then they have probably found a way of making >> themselves very famous, rich, and winning all sorts of prizes. > > Ignorance is Bliss?
Bliss? That was a real language for real programmers! ;) Wouter
The 2026 Embedded Online Conference