DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: The Most Expensive One-byte Mistake: Nice article about programming design goofs  (Read 7,282 times)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Fun article:

Quote
The best candidate I have been able to come up with is the C/Unix/Posix use of NUL-terminated text strings. The choice was really simple: Should the C language represent strings as an address + length tuple or just as the address with a magic character (NUL) marking the end?


http://queue.acm.org/detail.cfm?id=2010365


Screenshot - 8_3_2011 , 2_31_56 PM_thumb.png


from The best candidate I have been able to come up with is the C/Unix/Posix use of NUL-terminated text strings. The choice was really simple: Should the C language represent strings as an address + length tuple or just as the address with a magic character (NUL) marking the end?

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • Cody Award
    • Official Forum Clown
    • rotten turkey sandwich - Rotten Turkey Sandwich
The Most Expensive One-byte Mistake

Wasn't that Eve's?
Chris

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 9,827
    • Participated in NANY Challenge Eight Times
    • Cody Award

f0dder

  • [Well, THAT escalated quickly!]
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
    • Participated in NANY Challenge Once
Should the C language represent strings as an address + length tuple or just as the address with a magic character (NUL) marking the end?
If it had done anything else, the situation would probably be worse today.

NUL-terminated strings aren't optimal, but they were the logical choice back then, and are better than some of the alternatives. The BIG mistake is how a lot of the libc (and especially the string functions!) were designed.
- carpe noctem

Original address: https://www.donationcoder.com/forum/index.php?topic=27540.0