Hello C++

We have started working on C++. As you can see in the screenshot, we can do the basic OO stuff, as one would expect (click on the picture to be able to read the code).

C++ is a really complicated language, and we haven’t decided yet on how much of it we’re actually going to implement. Especially the type system for the template stuff is really advanced. It would help us if you could let us know how much of C++ is typically used in embedded systems? Also keep in mind that many of the things that today are done with template meta programming can simply be implemented as a language extension with MPS!


6 thoughts on “Hello C++

  1. First of all, thank you for all this cool stuff ๐Ÿ™‚
    I’m really a bit euphoric about the availability of such an useful tool for the embedded domain. After years of oppression by UML modelling tools it could bring back productivity and joy to programming!

    From my point of view the most useful C++ features in embedded development are the simple ones. Interfaces through abstract base classes and the ability to easily create multiple instances of types.

    After a first look at your documentation I haven’t felt a desire for C++. As far as I understood, these features are already implemented in your C extensions through interfaces and components? Of course single inheritance and polymorphism come in handy sometimes, but I liked your original concise C approach with domain specific extensions. More sophisticated general purpose language features could make it more likely that you blow your whole leg off (as the old C++ saying goes)…

    My impression was always that the biggest productivity boost in C++ comes from the more powerful library (STL). But of course a STL needs C++ templates and besides that, it is questionable if it is suitable for embedded systems (dynamic memory allocation, etc.). A small, standardized set of well tested C collection modules and search/sort algorithms could ease the pain (oddly, there’s nothing like that in the C world…).

    I’m wondering if you emit C++ code or still C? If it’s C, I can image that the generated code for more complicated C++ constructs can get very unreadable. Even if it’s not desirable to to look at generated code, I think in practice it will be necessary from time to time.

    OK, I think it is clear that I’m not a fan of C++ but if you’re looking for ideas how an embedded C++ subset could look like, you may find EC++ interesting (if you aren’t already aware of it) http://en.wikipedia.org/wiki/Embedded_C%2B%2B.

    If I had a wish, I would like to see focus on features like some kind of help for the design of real-time applications, threading, generation of requirements/unit test traceability matrices and documentation generation. Could there be, for instance, a kind of “super doxygen”, using the possibilities of the language workbench? Generating complete architecture and detailed design documents?

    • Hallo Ulf,

      your first paragraph sums up nicely what we’re trying to do ๐Ÿ™‚

      Yes, interfaces and components are supported even without C++ and I agree with the “blowing your leg off” risk. We need a minimum of C++ at least to interface with C++ libs. Even Arduino requires that ๐Ÿ™‚ STL support would of course be a good thing, but I haven’t seen it used much in embedded systems. I may be wrong there, though.

      We emit C++ code. We don’t transform it back to C.

      Thanks a lot for the EC++ link. I actually wasn’t aware of it. C++ is not my specialty ๐Ÿ™‚

      We would certainly *love* to address realtime stuff. However, we need external support here, because we don’t have the necessary expertise on the team.

      Rerding the generation of design documents: you can embed documentation in the code, and, as you’ll see in the next blog post, we can also do visualizations via graphviz. And we have traceability. That’s at least first steps towards a “super doxygen” ๐Ÿ™‚

      Thank you for your detailed comment!!


  2. C++ seems like unnecessary feature creep at this point. The Creeping Feature Creature can be a powerful task master.

    Many of us in the Embedded Space would like to see a modern functional language that can be compiled down to basic C code.
    Once that goal is achieved and everything is up on GIT Hub, then it might be reasonable to do something with C++.

  3. I developed successful commercial applications with c++ for embedded consumer electronic systems. We used Rational Rose for modeling and code generation in C++. C++ is much more expressive than C and provides full control on footprint and speed. Due to its object-oriented nature it provides all the benefits of this mindset to embedded systems. Iยดm sure that C++ is going to replace C in the future, e.g. IAR offers for a huge set of embedded microcontrollers a good commercial C++ compiler (even for 8+16 bit machines e.g. MSP430 series).
    Therefore I like the idea of having C++ as a base-language in MPS. C++ templates are another mighty development feature.
    Since I do not have experience in terms of how template functionality can be provided by MPS it would be helpful to me if you could provide a real world example in MPS on how template functionality can be expressed.
    I think the decision on providing C++ templates should be driven by the effort required to provide the same kind of abstraction in MPS.
    Anyway, having even a subset of C++ available is from my point of view a good step, since more and more compiler-vendors provide C++ compilers for embedded systems.
    P.S.: Today I work on automotive applications, but even there we start using C++.

    • Hi Rudolf,

      At this point our C++ cannot do templates. And as I said in the post, it is not clear to me yet how much we have to. There will be some, I am sure.

      What I was trying to say way this: instead of “mis”using templates for meta programming, you can just as well create a “real” language extension. For example, some people use templates in physical units (SI units) or for state machines. We (will) provide native support for these, so templates aren’t necessary there. But we don’t have a generic replacement for templates. But as I said: I am sure we will have some of it.

      And yes, I agree that more and more people use C++ in embedded systems — the questions really is: which of the features.

      I guess we’ll have to explore this a bit deeper ๐Ÿ™‚

      Thanks for your feedback!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s