My overlords have tasked me to fix a rather sticky, noisome bit of coding horror whose SQL parser is in need of repair (it needs an overhaul, but thats too risky). Actually, there are 2 or 3 SQL parsers in this pile of codegoo (after all, one is never enough!)
After 6+ hours of hair tearing, teeth gnashing and screaming at the walls while attempting to fix this coding disaster, I note the following harmless bit (coded with the rusty straight razor of 'C'):
if (token == '\n')
and realize the source of my angst. For the 768,529th time in my coding career, I've been a victim of the longest running practical joke in software development: Microsoft's schizoid newline character. After correcting the offending code, which fixed the problem, I decided I'd had enough for the day, and retired to idle repose with a tasty homebrew and cigar. After a moment I began to ponder
The half pint of 13% ABV trippel then caused a mental segue to Bill G.'s recent stunt. While I applaud Mr. Gate's philanthropy, I would have liked to inform his audience that, as a software developer, I'm very accustomed to Bill G & Co. purposely releasing bugs to the public.
<rimshot/>
"Just add water, makes its own sauce..."
I dislike Microsoft as much as the next guy (probably more), but the history says that the real blame here is in the design of printers. As a result the division between systems that used \r\n versus \n goes back to the mid-60s, which is comfortably before either Unix or Windows was created.
In particular Windows inherited \r\n from DOS, which got it from 86-DOS which Microsoft purchased the rights to use from Seattle Computer Products in 1980, which in turn implemented \r\n because it was a CP/M clone and CP/M did it that way, and CP/M did it that way because when you've got an 8-bit processor and 16K of RAM, trying to auto-translate \n into \r\n for the printer doesn't make much sense. (And, of course, once you have programs that depend on \r\n being there, backwards compatibility makes that choice hard to change at any point in time.)
By contrast Unix got the \n convention from Multics, and both Multics and Unix ran from the start on much more powerful machines than CP/M did, so convenience details like auto-translating \n into \r\n on the fly made more sense.
Don't ask me why Macs versions OS 9 and earlier wanted to use \r as a line ending instead of \n. Luckily that choice is now ancient history and we can all forget about it.