This is a thought I've been mulling on for a while now....
I recently finished working on prototyping an auto-balancing robot. I used the Tiva C Launchpad since the TM4C123GH6PM microcontroller that comes on the board is well-suited for the realm of robotics.
In my extensive Google searching for information when working on the project, I found most C and C++ libraries written for embedded applications are platform dependent, non-generic, and have non-modular algorithms. This makes porting these libraries to other platforms (like the Tiva C) significantly more difficult. What I mean by these terms:
1) Platform Dependent
Written for a specific architecture. The functioning of the code is tied intimately to the specific microcontroller or microcontroller family for which it was written. For example, the code used in the library uses a specific driver library or certain registers. This makes porting to other embedded platforms/architectures especially difficult.
2) Non-Generic
Only works for a narrow setup. For example, a button debouncer library that can only work for two buttons. TI actually wrote a button debouncer library for the Tiva C Launchpad that could only debounce the two onboard buttons on the Launchpad.
3) Non-Modular Algorithms
In order to use a specific algorithm in the library, all algorithms must be subscribed to. For example, think of a library that tries to do a little of everything, which thus makes the library large (code wise). If I wanted to use just a small subset of the library's functionality, I would have to include the entire library including the superfluous aspects to my application.
To improve library modularity and reduce porting time, libraries can be written as so:
1) Platform Independent
Will work regardless of architecture. The algorithm and architecture implementation are separated. For example, the algorithm has its own separate header and source file while the architecture implementation has its own header and source files as well. This greatly reduces porting time since the algorithm specific file is completely architecture independent and thus can be ported instantly.
2) Generic
Works for a wide variety of setups. For example, a button debouncer algorithm that can grow with the amount of buttons in use.
3) Modular Algorithms
The algorithms are written for a specific use. For example, a matrix library that tries to do both floating point and fixed point matrix algebra can be split into a separate floating point matrix library and fixed point matrix library.
Example of Platform Dependent Libraries
Most Arduino Libraries
Example of Platform Independent Libraries
FatFs and Petite FatFs
Most RTOSes
If libraries were originally written with those latter qualities in mind, I don't think I would have had nearly as tough of a time with my robotics project.