r/cprogramming • u/Xaneris47 • Aug 17 '26
C Strings: A 50-Year Mistake
https://longtran2904.substack.com/p/c-strings-a-50-year-mistake?r=8qz2zb&utm_campaign=post&utm_medium=web
212
Upvotes
r/cprogramming • u/Xaneris47 • Aug 17 '26
View all comments
Show parent comment
1
u/SmokeMuch7356 Aug 19 '26
Array expressions decay to pointers because Ritchie wanted to keep B's array indexing behavior -
a[i] == *(a + i)- without setting aside storage for the pointer that behavior required.That's it. That's the reason.
These were researchers in a lab building toys that did useful things for them. None of them anticipated how C would become so widely used at an applications level. That was the mistake, the fact that everyone looked at C and said "yes, that's the answer," but to be honest there weren't many better candidates that could be ported to everything from mainframes to micros. Pascal? Eh. Designed more for teaching than production work. Fortran? =snort=. Didn't even support a real string type until F77. Cobol? Double =snort=. Didn't help that C and Unix were (are) joined at the hip; if you were using Unix, you were writing code in C for pretty much everything.
C was small enough and lightweight enough it could be ported practically anywhere, particularly micros, and that's why it suddenly became the language everything was written in.
And here we are 50 years later arguing about it, when it shouldn't even be considered for applications work involving text processing anymore.