View Full Version : C and C++ binaries

01-09-2002, 02:11 PM
In embedded systems, software should be

1. very small
2. very fast
3. take very less working memory.

At this moment C and C++ are the most used languages, sometimes some parts of the software are written in assembly.

When looking at speed and memory-use I don't think that C and C++ differ a lot. So the main think to look at is size.

Today I was discussing the performances of C and C++ with some collegues. One collegue told me that it is possible to write C++ code which results in smaller binaries than C. Though I allways thought that C++ would result in large binaries.

What language would you use when it comes to size?

01-09-2002, 03:07 PM
Unless you were using one of C++'s more expensive features I don't think there'd be much (if any) difference in the size of the code generated but I don't know how you'd get smaller code from using C++ alone. It would probably depend on how good a job the optimser was doing for a particular compiler, not which language.

If you knew what you were doing and didn't mind spending the extra time then I'm sure you could use asm to make the code smaller and faster.

01-10-2002, 02:16 AM
I have programmed embedded systems for years, (my first "embedded" system was 1983). In that time things have changed a lot, mostly because of the increased capabilities of the chip manufacturers. In the early days it was necessary to write in either machine code or if you were lucky, an assembler. As the chips grew in complexity, more could be squeezed into less silicon, so you could afford a little overhead if it cut development time, and made maintenance easier. Today, we can embed a machine with a full multitasking OS, and write complex, multithreaded, fully object oriented programs.

Bottom line, these days, the chips have so much on them, they are not the limiting factor, time to market is probably the biggest criteria now in deciding the fate of an embedded system. Nobody wants yesterdays model.

01-10-2002, 12:36 PM
Yes, electronics today is able to handle very complex software in a relative inexpensive way. Currently at work I'm on a project concerning a navigation system for cars. It's amazing how much functionality can be put in that little box.

Time-to-market is very important these days, though I don't matter very much about that. The technical challenge means more to me than the marketing/financial-stuff, but I know it's important to keep those stuff in mind.

A very remarkeble point in software projects is that the software is growing and growing. But at a point near the end the software seems to decrease in size. I don't know why, perhaps it has to do with optimizations which are going on in the later phases of a project.

I'm working for three years on embedded systems now and I only used C and C++. Since the project I'm working on is just my second large project, I have not enough experience to note the differences. But as I understand from both of you: it doesn't really matter if you're using C or C++.

Besides. What do you think is important for embedded systems programmers to learn these days in your opinion? I've been told that Java is getting very important since many machines are being equipped with internet technology.