a firstworks project
Rudiments
About Documentation Download Licensing News

C++ As a Better C

There's this old joke about C++...

Developer's Insight, December 1991 (approx version)

How to Shoot Yourself In the Foot (in various programming languages)

C++
You accidently create a dozen instances of yourself and shoot them all in the foot.
Providing emergency medical assistance is impossible since you can't tell which are
bitwise copies and which are just pointing at others and saying "That's me, over there."

While perhaps true in '91, I contend that the situation has gotten even worse since then.

Not that C++ isn't a massive improvement over C, but its features give rise to a list of drawbacks:

Or, at least, I've been frustrated by each of those problems at one time or another, over the years.

The standard API's for many other high level languages seem to just implement paradigms established by C in an object oriented manner. Rudiments takes this approach too, in effect, using "C++ as a better C".

Further, rather than abstracting the entire set of Posix and Windows errors into hundreds of individual exceptions, Rudiments' methods throw no exceptions and generally return true on success and false on failure. Since most methods just wrap C functions, errno is set when a method fails, and the error class (which wraps errno) can be used to get the specific error number and string.

As such, Rudiments can be compiled with the -fno-exceptions flag to conserve space on resource-limited platforms.

Rudiments doesn't use any dynamic_cast operations internally either, so if your applications don't do any run-time type-checking of Rudiments classes, then Rudiments can also be compiled with the -fno-rtti flag to further conserve space on resource-limited platforms.

Copyright 2017 - David Muse - Contact