(C++) Why do you put sub-optimal code on your site?

January 10, 2018 ยท View on GitHub

FAQ.

I have two reasons why I sometimes choose to put sub-optimal code on my site:

  1. The compiler I used did not correct me (where others/yours will)
  2. I lacked the time to make it better

Both reasons are explained below in more detail.

The compiler I used did not correct me (where others/yours will)

I always compile clean at high warning level [1] and I always put cleanly-compiled code on my site.

But compilers differ. So, when I work with compiler X, I will put the cleanly-compiled code on my site. When I start working with compiler Y, I will put other cleanly-compiled code on my site.

I know that some of my code snippets do not work under some compilers.

I lacked the time to make it better

Sometimes, I do have a time schedule. Instead of drifting off, I choose to create a version that 'just works'. Feel encouraged to contact me if you have an improved version of a code snippet.

References

  1. Herb Sutter, Andrei Alexandrescu. C++ coding standards: 101 rules, guidelines, and best practices. 2005. ISBN: 0-32-111358-6. Item 1: 'Compile cleanly at high warning levels'.