Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!tank!uxc!uxc.cso.uiuc.edu!m.cs.uiuc.edu!gillies From: gillies@m.cs.uiuc.edu Newsgroups: comp.arch Subject: Re: Endian wars Message-ID: <3300050@m.cs.uiuc.edu> Date: 7 Feb 89 03:19:00 GMT References: <6133@columbia.edu> Lines: 31 Nf-ID: #R:columbia.edu:6133:m.cs.uiuc.edu:3300050:000:1218 Nf-From: m.cs.uiuc.edu!gillies Feb 6 21:19:00 1989 /* Written 12:25 am Feb 5, 1989 by PLS@cup.portal.com in m.cs.uiuc.edu:comp.arch */ This deserves a new subject. Since it was mentioned in the Endian Wars, does anyone know why C uses the null terminated string rather than an explicit length? ... - It removes a character from the character set, a source of many C bugs - All machines I know of that have character string instructions want the length of the string. This forces the string primitives to first scan for null, a time wasting operation. /* End of text from m.cs.uiuc.edu:comp.arch */ First, let me say that string type is a religious issue. I once worked for a workstation vendor whose main workstation had THREE different types of strings. Each development group claimed THEIR strings ran the fastest on the hardware platform. Every package had about 25 string subroutines, including 5-10 for "converting" "inferior" formats into "ours". Second, I was once told that the following C code compiles into 1 instruction (or something amazingly short) on the PDP-11, C's mother machine: while (*p++ = *q++); This is perhaps part of the reason why strings were designed with null-termination Don Gillies {uiucdcs!gillies} U of Illinois