Previous section   Next section

Imperfect C++ Practical Solutions for Real-Life Programming
By Matthew Wilson
Table of Contents
Prologue: Philosophy of the Imperfect Practitioner


The Spirit of Imperfect C++

As well as the tenets of Philosophy of the Imperfect Practitioner, this book reflects in general my own guiding principles in writing C++. These generally, though not completely, reflect the twin credos of the "Spirit of C" [Como-SOC]:

  • Trust the programmer: Imperfect C++ does not shy away from ugly decisions.

  • Don't prevent the programmer from what needs to be done: Imperfect C++ will actually help you achieve what you want to do.

  • Keep solutions small and simple: most of the code shown is just that, and is highly independent and portable.

  • Make it fast, even if it is not guaranteed to be portable: efficiency is given a high importance, although we do, on occasion, sacrifice portability to achieve it.

and the "Spirit of C++" [Como-SOP]:

  • C++ is a dialect of C with modern software enhancements: We rely on interoperability with C in several important cases.

  • Although a larger language than C, you don't pay for what you don't use (so size and space penalties are kept to a minimum, and those that do exist must be put in perspective since what needs to be compared is equivalent programs, not feature X vs feature Y).

  • Catch as many errors at compile time as possible: Imperfect C++ uses static assertions and constraints wherever appropriate.

  • Avoid the preprocessor when possible (inline, const, templates, etc. are the way to go in most cases): we look at a variety of techniques for using the language, rather than the preprocessor, to achieve our aims.

Beyond these tenets, Imperfect C++ will demonstrate an approach that, wherever possible:

  • Writes code that is independent of compilers (extensions and idiosyncrasies), operating-systems, error-handling models, threading-models, and character-encodings

  • Uses Design-by-Contract (see section 1.3) wherever compile-time error-detection is not possible


      Previous section   Next section