From -1960983486795958927
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,1a41e51653d5c16a
X-Google-Attributes: gidf78e5,public
From: bs@research.att.com (Bjarne Stroustrup)
Subject: Re: C++ for embedded systems
Date: 1997/07/09
Message-ID: <ED1z7w.LI5@research.att.com>#1/1
X-Deja-AN: 255809567
References: <rf5g1tvkpvm.fsf@vx.cit.alcatel.fr> <ECyA17.HpE@research.att.com> <rf52059nbuh.fsf@vx.cit.alcatel.fr>
X-Original-Date: Wed, 9 Jul 1997 13:09:32 GMT
Organization: AT&T Research, Murray Hill, NJ, USA
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBM8PoZEy4NqrwXLNJAQFBoAIAhHfHuyoi0bWnXmyoPcMZcDz1PquUYzQe ZM0VVhlJXSUuB4gvQSiH90ux6SGLMQryMvkeX8W7B3sHcd9vr1blAw== =3qAt
Newsgroups: comp.std.c++
Originator: austern@isolde.mti.sgi.com


James Kanze <james-albert.kanze@vx.cit.alcatel.fr> wrote:

 > bs@research.att.com (Bjarne Stroustrup) writes:
 > 
 > |>  Martin Lang <Martin.Lang@stgl.sel.alcatel.de> writes:
 > |>  
 > |>  |>  I heard some rumours about a stripped down version of C++ that
 > |>  |>  can be used for embedded systems.
 > |>  |>  
 > |>  |>  Does anybody know more details? Do any proposals already exist?
 > |>  
 > |>  The key to successful use of C++ for embedded systems is a modest
 > |>  amount of understanding of how code is generated rather than artificially
 > |>  stripped down versions of the language. For starters, "embedded systems"
 > |>  is a label that covers a lot of diverse needs.
 > |>  
 > |>  If you chose a "stripped down version," be sure that it is a subset of
 > |>  the (draft) Standard C++ and its library rather than a dialect.
 > 
 > I think that this is the intent of the EC++ group.  As I understand it,
 > 100% of the programs written in EC++ should be legal C++ programs, with
 > the same semantics.

P.J.Plauger has assured me that the aim of EC++ is to be a compatible subset
of Standard C++.


 > I don't think that their goal is to criticize C++
 > per se.  In the rest of you posting, you correctly point out that when
 > programming for embedded systems, you will probably only use a subset of
 > C++.  I think that there main goal is to standardize what that subset
 > should be.

First, I was speaking of "stripped down" versions in general, not just
about the EC++ effort.

Second, I'm not sure that it makes sense to "standardize" a subset of
C++ for embedded systems unless you can specify clearly what "embedded
systems" means in a specific context.

Third, it would be a mistake for a programmer to think that he/she would
have to wait for some "approved" subset to come into existence before C++
could be used for embedded programming. I fist used C++ (or rather C with
Classes) for something that could be called embedded programming around 1981.


 > A second goal might be to do it now.  I don't think that anyone would
 > argue that templates are inherently a problem for an embedded system.
 > But the exact semantics of templates are still being discussed (or were
 > a couple of weeks ago).  In the information I read about embedded C++,
 > templates were not included exclusively for this reason.

I certainly wouldn't argue against templates for embedded systems, and I
don't think the EC++ people are doing that. My impression is that they
left out template out of lack of available compilers and lack of experience
with templates. The initial EC++ discussions were two years ago. I suspect
that was the decisions reviewed - as they surely will when the standard
gets to the next stage - templates will be explicitly endorsed.


 > I think that their goal is laudable.  Basically, what they are saying
 > (or what they seem to be saying, to me) is that here is a subset of C++
 > that you can safely use today in a particular subset of the
 > applications.  I don't see this as a criticism of the rest of C++, but
 > simply recognizing the realities of today, and current compilers.

Aside: I was not under the impression that I was defending C++ against
critisism in my posting.

What you can safely use depends on what you are doing, who you are, and what
tools you have available. EC++ might be good for someone, but that doesn't
imply that features not included are unsuitable for everyone doing some form
of embedded programming. It would be sad if people drew that conclusion from
the EC++ effort, because that would lead people to back out of some effective
practices.

For example, templates have been used successfully for embedded programming.
In particular, at the USENIX COOTS conference last month there was a paper
describing some embedded programming in C++. I think that a fair summary
of the author's statement on templates is: "If you don't know what you are
doing, you can get code bloat, but there are things that you can do more
elegantly with templates than without them, and at least as efficiently." 
That's very close to my opinion on the subject.

	- Bjarne

Bjarne Stroustrup, AT&T Research, http://www.research.att.com/~bs/homepage.html
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]



