Delivering an API that is data aware by using ANSI C/C++ compilers’ ability to type check function arguments.With embedded software adding intelligence to so many everyday objects, it seems remarkable that the tools used to create these programs aren’t smarter when it comes to catching highly destructive bugs. In assigning blame for such errors, one culprit lies in the application programming interfaces (APIs) provided by software publishers. Developers have long chosen libraries of pre-built software for communication, data management, messaging and other purposes rather than creating this functionality from scratch.
Read the article by Steve Graves at LinuxJournal.
I’m afraid that this is not new or interesting (e.g. CORBA’s idl -> native language has done this for years, as do other SQL framework generators), but by the looks of it an advertisement for technology sold by the authors company. It’s hardly a ‘self-diagnostic API’ either. The use of a pre-processing stage to generate .c/.h files is itself a hallmark of last-generation technology – we now live in the world of dynamic type and data checking. If we were really taking about a ‘self-diagnostic API’ it would have inbuilt smarts to check types, check states, check consistency and so on. I’m sorry I wasted my time reading it.
A major improvement can be had by switching to a more type safe language. Although, C and C++ can do some rudementary type checking, they are quite fast and loose about it(I’ve programmed in C since ’86 and in C++ since ’95).
A much better language is Ada95. It allows you to do everything C++ does (aside from multiple inheritance – and I’ve never seen a good example of MI, except to inherit interfaces, which Ada permits). As well you get the benefits of really strong type checking (which you have to explicitly disable), real user defined types (no chance of accidentally mixing height and weight), multi-tasking is part of the language, distributed computing is an optional part of the language, real-time is another optional part of the language. Generics (templates) have been part of the language since ’83. Low level programming is also easy and type safe.
Ada is defined as a core language (that must be implemented in order to be called Ada) with a specialized needs annexes that define other specialized behaviour (systems programming, real-time, distruted systems, information systems, numerics, safety and security).
I switched to Ada95 after many years of coding in C++ because Ada is much more the language I wanted C++ to be. It is the same reason I switched years ago from assembler to C, because C was much more the language I wanted assembler to be.
Of course, not everything is rosy, third party libraries in Ada are scarce. But, it is fairly easy to interface to other languages and libraries.
The language got a bad rap back in the early ’80s because it was far more advanced and made more serious demands than any language at the time. Imagine if C++ was being proposed back in 1980. Compiler and language technology just wouldn’t have been able to deal with it (a fully conformant C++ compiler on a 64K Apple II?).
If you don’t think that MI is an important capability of C++, you need to read Alexandrescu’s work on policy classes. This concept allows you to program at a much more expressive level–more like writing a specification almost–and cannot be implemented using mere interfaces, since you literally build an entire class by specifying a set of objects from which it inherits.
I know the book and I must assess that I still don’t think that MI is really worth it. The interface concept is more than enough
I am yet to see a real world project that beneficts from having MI instead of single inheritance with interfaces.
Thanks, I’ll look up Alexandrescu’s work.