Critical Section


one byte mistake

Sunday,  08/28/11  07:46 PM

I don't always null-terminate my strings...An article in ACM by Poul-Henning Kemp claims the decision to null-terminate strings is the most expensive one-byte mistake.  Not even.

Null-terminating strings was a great design decision, especially compared to the alternative of preceeding each string by a length.  First, a length "byte" would be just as prone to being corrupted as a null terminator, maybe more so.  Second, who's to say one byte is enough?  255 characters isn't very many, and if you need more than one byte, how many more?  Always two?  Always four?  If it's variable, how do you know?  Big endian or little?  Or both?  Third, how do you handle variable-length strings which grow - do you reallocate the whole string to make the length byte bigger?  The problems go on and on.

As the author notes, C has mostly be replaced by ${lang}, and in ${lang} you have string objects which encapsulate the byte arrays anyway.

The real most expensive one-byte mistake was using backslashes as path delimiters in DOS, which is even mentioned in this article.

Home
Archive
flight
About Me
W=UH
Email
RSS   OPML

Greatest Hits
Correlation vs. Causality
The Tyranny of Email
Unnatural Selection
Lying
Aperio's Mission = Automating Pathology
On Blame
Try, or Try Not
Books and Wine
Emergent Properties
God and Beauty
Moving Mount Fuji The Nest Rock 'n Roll
IQ and Populations
Are You a Bright?
Adding Value
Confidence
The Joy of Craftsmanship
The Emperor's New Code
Toy Story
The Return of the King
Religion vs IQ
In the Wet
the big day
solving bongard problems
visiting Titan
unintelligent design
the nuclear option
estimating in meatspace
second gear
On the Persistence of Bad Design...
Texas chili cookoff
almost famous design and stochastic debugging
may I take your order?
universal healthcare
entertainment
triple double
New Yorker covers
Death Rider! (da da dum)
how did I get here (Mt.Whitney)?
the Law of Significance
Holiday Inn
Daniel Jacoby's photographs
the first bird
Gödel Escher Bach: Birthday Cantatatata
Father's Day (in pictures)
your cat for my car
Jobsnotes of note
world population map
no joy in Baker
vote smart
exact nonsense
introducing eyesFinder
resolved
to space
notebooks
where are the desktop apps?