Valladolid Code Retreat, May 2011

I have just attended a Code Retreat event in Valladolid, facilitated by Enrique Comba Riepenhausen. This was an excellent opportunity to meet fellow geeks interested in continuous learning, that were willing to spend a whole Saturday doing pair programming, exchanging ideas about processes and agile practices, and above all, having fun!

Learning is about getting out of your comfort zone, which was definitely my case, as I had to follow practices like TDD or pair programming, and I even paired with guys writing groovy, although the most popular languages were java and python.

Thanks a lot to Enrique, the sponsors and the organizers!

I can only encourage you to look for Code Retreats in your area, or why not organize one yourself? Really worth it!

C++ for embedded?

Recently I was asked by a client about the advantages of C++ over C for a specific embedded project, and these are the ideas I came with:

C exhibits a narrower relationship between source and machine code, which sometimes makes debugging and code optimization easier. Some architectures also have better compiler support for C, although this applies chiefly to some not very common DSPs. In some cases, C may also provide more efficient usage of memory and a reduced runtime when compared to C++.

On the other hand, C++ provides many facilities through the STL that are not part of the standard C library. C++ facilitates information hiding and object orientation in cases where it might be useful. In addition to this, C++ exceptions simplify error handling without the error checking code frequently spread throughout a C program.

I don´t think other C++ features like templates and RTTI are so useful on embedded systems. If your compiler lets you turn these off completely, I would advise you to do it in order to get significant code size savings. It is always advisable to write a test program to check how well your compiler does with C++ features enabled.

The usage of C++ should be mandated by whether their features make sense in your product and a careful evaluation of the benefits they provide against their performance/size costs.