Generi-C is an enhancement of the enormously successful programming language C being still very popular especially in the field of embedded software, which has been carefully extended by some vital language elements in order to optimize the reusability of software parts. As far as we known Generi-C is the first programming language supporting the following three reuse techniques at the same time:
- Generic Programming: software parts developed in Generi-C similar to modules in conventional C are automatically and without further effort by the developer generic parts which can be instantiated and specialized for different applications.
- Component-oriented Programming: the software parts developed in Generi-C are always strictly separated components with defined interfaces which are interconnected in a specific form for the respective application at first.
- Partial Evaluation during build time: the program code of the software parts developed in Generi-C is evaluated as far as possible during the configuration of a component at build time in order to remove code that does not need to be evaluated at run time any more for the given application-specific configuration.
The combination of these techniques in a low level system programming language close to the hardware and derived from C offers the possibility to reuse software parts in the embedded software area in the most flexible way using generic and component-oriented programming while the resources used for these software parts are minimized by the partial evaluation of the program code at build time to the extend really needed by the respective application, which is still very important especially on low power (and low cost) microcontroller systems.
The programming language Generi-C extended by only a few component elements is mapped to ANSI-C by a dedicated pre-compiler called Composer. Basically only the two keywords component and interface were added to the C programming language while the syntax was kept analogue to the other C language elements. The compelling integration of the C-pre-processor is no longer necessary. The pre-compiler maps the component definitions, controlled by component configurations, on C and H source code files as described below:
An outstanding feature of this solution is the generic configurability of all software components based on it without the component developer having to add any configuration instructions. Thus each component can be adjusted to the respective application in the best possible way without additional expenditures and its use of resources can be minimized. Hence even the smallest software elements can be reused without overhead as so-called MicroComponents.
A component definition in Generi-C syntactically equals a complex type declaration in C, however, semantically it rather equals a template in C++ (it differs however significantly), as no binary code is generated here. A component configuration, on the other hand, syntactically equals an initialized variable definition in C, but semantically it rather equals the use of a template in C++; the binary code is generated not until here. Generi-C could thus also be called Templates for C.
Generi-C supports the simple inheritance of interfaces like for example COM as well as the multiple one, but not the inheritance of program code like C++ as this contradicts the component concept which is stronger aimed at information hiding. Also in the so-called object-oriented programming abstract base classes are used more and more often in order to avoid the known fragile base class-problem. Abstract base classes, however, are nothing else than interfaces!
It is referred to external components and interfaces via qualified names as in Java. This concept leads to a very advantageous recursive structure. Each set of configured and linked components in a file can on its part be regarded again as a component. This way a conventional C module in which no pre-processor-instructions like for example #include are found, can be directly regarded and used as a component without further changes.
When describing the interface elements of a component additional attributes like in OSF DCE IDL can be used. This way it is made possible to describe generic Marshalling of function calls and to especially support systems with different priority levels as well as distributed systems.
Our solutions is based on the definition of a minimal extension of the standardized programming language C in order to allow component-oriented programming of embedded software at system level in the first place and therefore provide better means to reuse these software parts. Through the possibility to generically configure every software component these components can be fitted especially to the respective application without consuming more resources than absolutely necessary, which makes our solution ideal for low-end embedded systems which very few resources.
Our approach has the advantage of being able to define really encapsulated components in contrast to the attempt to realize reusable, adaptable components by using C++ templates. The components defined with our approach can be fully checked and tested while a low of checks by a C++ compiler have to be postponed to the instantiation of a template which typically leads to cryptic error messages produced for the end user with reference to the template code that the end user doesn't know so that the realization of really encapsulated components is not possible using C++ templates.
Already existing component models for Embedded Software (like ECOS Component Model, Koala, Knit, TinyOs/nesC, Real-time Corba, Minimal Corba) have typically been developed for special projects, special industries, special platforms or special compilers and components developed with these systems are therefore not really universally reusable even on resource-constrained 8 bit microcontrollers.
A detailed technical paper with an in-deep presentation of our innovative component technology in PDF format can be found here. If you have further interest in Generi-C and like to obtain more information as well as a test version of our Composer, please contact us here.