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
'11   '10   '09
'08   '07   '06
'05   '04   '03
flight
Re:Cycling
Re:The Book
Re:Software
Re:Philosophy
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
Google and Blogs
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
Most Spectacular Photos of 2003
In the Wet
the big day
solving bongard problems
visiting Titan
unintelligent design
Shorthorn
the nuclear option
second gear
On the Persistence of Bad Design...
Texas chili cookoff
the inflection point
almost famous design and stochastic debugging
may I take your order?
paper art
triple double
China's olympic gardens
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
room with a view
weird disaster update
in praise of paddle shifting
the first bird
Gödel Escher Bach: Birthday Cantatatata
shining a light
Father's Day (in pictures)
Tour de France 2009
Tour de France 2010
Jobsnotes of note
Tour de France 2011