Jan. 4th, 2017

henry_flower: A melancholy wolf (Default)
Date: Tue, 03 Jan 2017 15:19:08 -0500
From: Doug McIlroy <doug-bjgkzyaamjvekzp4s/tgzg@public.gmane.org>
Newsgroups: gmane.org.unix-heritage.general
Subject: Re: Mac OS X is Unix
User-Agent: Heirloom mailx 12.5 7/5/10
Message-ID: <201701032019.v03KJ8oq028944@tahoe.cs.Dartmouth.EDU>

> keeping the code I work on portable between Linux and the Mac requires
> more than a bit of ‘ifdef’ hell.

Curmudgeonly comment: I bristle at the coupling of "ifdef" and "portable".
Ifdefs that adjust code for different systems are prima facie
evidence of NON-portability. I'll buy "configurable" as a descriptor
for such ifdef'ed code, but not "portable".

And, while I am venting about ifdef:
As a matter of sytle, ifdefs are global constructs. Yet they often
have local effects like an if statement. Why do we almost always write

#ifdef LINUX
        linux code
        default unix code

instead of the much cleaner

                linux code
                default unix code

In early days the latter would have cluttered precious memory
with unfreachable code, but now we have optimizing compilers
that will excise the useless branch just as effectively as cpp.

Much as the trait of overeating has been ascribed to our
hunter ancestors' need to eat fully when nature provided,
so overuse of ifdef echos coding practices tuned to
the capabilities of bygone computing systems.

"Ifdef hell" is a fitting image for what has to be one of
Unix's least felicitous contributions to computing. Down
with ifdef!