Hi,
Gautier has already pointed out some of the reasons why we are using C and not C++.
Regarding abstraction/encapsulation and ease of learning the system: I'm not really sure that C++ necessarily helps for the overall picture here...
(Keeping in mind that some of the C stuff is not well written and is being refactored whenever there is need and especially time.)
Some more personal remarks (disregarding the all the work that would be needed to convert to C++):
- Yes, we need to get rid of quite a few macros, a lot can be converted to plain (inline) functions directly or just written better in C.
Quite a few (generated) macros can't be nicely replaced by templates...
- For math functions and the like, function and operator overloading would help. And templates...
Although you have to be careful with templates... (also while most my code at work is heavily templated, I hate debugging that stuff)
- While a lot of things that are usually encapsulated in classes can be done in C as well, classes are IMHO often a bit nicer to read.
- Most of configuration options, etc.. are designed to be done at compile time and not runtime anyway.
I convinced this is a good idea, as most things you don't want to change in flight anyway and
it means you don't have to deal with the problems that come with runtime changes...
In C++ you have to be really careful about what functionality you use on an MCU system, but it is certainly possible and has it's benefits.
But also IMHO the potential for (accidental) screwups in C++ is much greater and my experience is that once you allow people to use advanced (C++) features, they will get used sooner or later without actually keeping the MCU constraints in mind. You end up with dynamic memory allocation where you didn't expect it, templates quickly get out of hand...
From my standpoint (and in a perfect world) we would use C++, but restrict it to a certain subset which is really beneficial for us.
So while I would like to be able to use some C++ features, I currently don't see this happening in paparazzi for two main reasons:
- It is a _lot_ of work and not clear if it's worth putting in all that effort to convert instead of improving code and providing new features...
- Some core devs prefer C over C++, and hence are not keen to put in time for 1.
In the absence of godly intervention to update our codebase in one go, it looks like in a lot of cases (e.g. driver encapsulation) incrementally writing better C code solves the problems or at least helps a lot....
Regarding python on the ground side:
There are already a few python implementations (e.g. of the messages tool, sim launcher, calibration/visualization scripts, documentation tools).
Personally I would like to see more of this, as I quite like python... but this can easily be done in parallel to the existing tools in most cases...
Cheers, Felix