Re: Null-terminated strings: the final analysis.



On 12/04/09 05:06, Tony wrote:
"Bartc"<bartc@xxxxxxxxxx> wrote in message
news:CFusl.4007$Lc7.1359@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
"Tony"<tony@xxxxxx> wrote in message
news:vsnsl.13862$W06.5350@xxxxxxxxxxxxxxxxxxxxxxx
Null terminated strings are premature optimization when considered in
modern times. Null-terminated strings are baggage and C suffers from
holding on to this obsolete implementation. (No question here, just
wondering now why a computer programming language should age like a
person?). Comments welcome of course.
This was discussed here recently, quite extensively too.

And they are not just a C thing, they were and are used ubiqitously
elsewhere, very successfully.

Your alternatives I recall would not fit easily into the low-level C
model.

"easily" is a subjective term, so your thought needs qualification to be
understood. I have a R&D design where a one-character string is one byte
(read no overhead),

What tells you it is one byte? Is it a special type ?
If so, er, isn't that called "char" in C?

small (Pascal) strings have one byte of overhead (the
length) and larger size strings have a few bytes more (but so what? they're
larger strings!). The usage though is via one abstraction.

FYI byte-counted strings aren't new and predate pascal - webearch for Hollerith string.

As criteria for string implementation analysis, I see: space efficiency,
time efficiency, practical usage (usage patterns are much different now than
then and the std implementation may be/may have impeding/impeded progress),

Some of the above may be true - C++ and Java use a form of byte-counted string. However note that C's model is likely to be the most space-efficient for non-trivial sized string, as the storage need be only one byte longer than the string, whereas byte-counted strings must be at least one byte longer.


--
Mark McIntyre

CLC FAQ <http://c-faq.com/>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
.



Relevant Pages

  • Re: C a Dead Language
    ... It is a major fallacy to claim the if as abstract in all usage. ... Now the Visual 6.0 enforece predicate test the geniuses theory. ... could be a string, say, 'www.complangc.net/files/' Although directories ... who have a parochial view of the C Programming Language or who think there ...
    (comp.lang.c)
  • Re: Scripts framework
    ... The usage library is a library that is allows command line scripts to ... Then set up the usage string for the command: ... and the usage for the program (hence the libraries name). ...
    (comp.lang.ruby)
  • Re: RfD: Number Prefixes
    ... for words that insert a character into an output number string, e.g., ... It's a popular bit of syntactic sugar that makes the 'pictured' number conversion more picturesque. ... I'd resist standardizing this usage for character literals. ...
    (comp.lang.forth)
  • Re: c / c++ : is it end of era ?
    ... the length of the string at each usage, ... In cases where checking string length is done often, ... crashing with division by zero? ... lcc-win32 allows you to test for overflow, ...
    (comp.lang.c)
  • Re: panic: uvm_mapent_alloc: out of static map entries ...
    ... I fubar'd the panic string... ... Is there a way to look at the usage of the mapent entries? ... vmstat -m doesn't ...
    (comp.unix.bsd.netbsd.misc)