Topic: C++ for embedded systems


Author: bs@research.att.com (Bjarne Stroustrup)
Date: 1997/07/09
Raw View
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
]





Author: James Kanze <james-albert.kanze@vx.cit.alcatel.fr>
Date: 1997/07/04
Raw View
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?

Check out http://www.dinkumware.com/.

--
James Kanze      home:     kanze@gabi-soft.fr        +33 (0)1 39 55 85 62
                 office:   kanze@vx.cit.alcatel.fr   +33 (0)1 69 63 14 54
GABI Software, Sarl., 22 rue Jacques-Lemercier, F-78000 Versailles France
            -- Conseils en informatique industrielle --
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: wkdugan@ix.netcom.com (Bill Dugan)
Date: 1997/07/04
Raw View
On 03 Jul 1997 09:14:45 PDT, Martin Lang
<Martin.Lang@stgl.sel.alcatel.de> wrote:

>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?

You can find a proposal at http://www.caravan.net/ec2plus/

A dejanews or altavista search of the C++ groups should turn up some
debate about it.
---
[ 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
]





Author: bs@research.att.com (Bjarne Stroustrup)
Date: 1997/07/07
Raw View
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.

C++ resource consumption is predicatable and - when you avoid bloatware
libraries - modest. For example, for a given implementation, the time and
space overhead f a virtual function is fixed, easy to calculate, and small.
See D&E or the ARM for the overall scheme and run a few experiments on your
system.

If you use operator 'new' to allocate memory from free store, you generally
need to be able to demonstrate that (1) allocations will succeed, and (2)
that there is no memory leaks or fragmentation. For these reasons, the
programmer of an embedded systems often has only two choices: (2) don't
use operator 'new' (2) supply your own implementation of operator new()
that meets your system constraints.

If you use exception in time critical applications, you need to know some
details of your implementation.

If you use templates you can get very fast and compact code, but you do need
to understand when code are generated for a template specialization to avoid
asking for many replications of very similar code.

Avoid libraries that are not written with embedded systems in mind.

There are compiler and library vendors that specialize in C and C++ for
embedded systems. Have a look in one of the journals that cover that field.

The bottom line: it has been done succesfully LOTS of times.

 - 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 news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: James Kanze <james-albert.kanze@vx.cit.alcatel.fr>
Date: 1997/07/08
Raw View
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.  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.

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 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.

--
James Kanze      home:     kanze@gabi-soft.fr        +33 (0)1 39 55 85 62
                 office:   kanze@vx.cit.alcatel.fr   +33 (0)1 69 63 14 54
GABI Software, Sarl., 22 rue Jacques-Lemercier, F-78000 Versailles France
            -- Conseils en informatique industrielle --
---
[ 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
]





Author: Martin Lang <Martin.Lang@stgl.sel.alcatel.de>
Date: 1997/07/03
Raw View
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?

Thanks

Martin Lang,
Rational Germany
---
[ 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
]