the zero terminated string is I think is computing's biggest mistake. Pascal style strings were much safer.
Zero terminated strings were the basis for an awful lot of useful software. Calling them the biggest mistake in computing is a bit OTT. I haven’t programmed anything Pascal related for 30+ years but I dimly remember thinking at the time that I wished the string system wasn’t so hard to use.
Linux eliminates the strncpy API after six years of work, 360 patches
131–140 of 340 posts
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#132A lot of pain and suffering to avoid having a string datatype.
No, a lot of pain and suffering to work around the lack of a string datatype in C.
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#133Re: Linux eliminates the strncpy API after six years of work, 360 patches
#134the zero terminated string is I think is computing's biggest mistake. Pascal style strings were much safer.
> Pascal style strings were much safer. The limitations were brutal. Initially you could only have 255 bytes in a string. The length of a string and the size of the allocation are now separate and you may need to think about that unused memory in your design. The problem now doubles with the introduction of UTF-8. Your string size is in bytes and you need to track characters separately. If you want to create an array…
Well yes, but given the number of security issues the argument is that it was in retrospect the wrong decision.
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#135the zero terminated string is I think is computing's biggest mistake. Pascal style strings were much safer.
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#136A reminder that we've had strlcpy [1] for ~ 30 years but it was never accepted into the Linux world because of typical petty open source bullshit. This is why we can't have nice things. [1] https://man.openbsd.org/strlcpy
The Linux kernel had strlcpy over 20 years ago. It was removed in favor of str s cpy because the latter was judged a better interface. Here's a 2022 article: https://lwn.net/Articles/905777/
The race conditions appear to be a result of the Linux kernel implementation but UNIX style syscalls introduce these races by default. It is not an inherent flaw of the API or even the implementation Linux was using.
The only useable C string API has always been memcpy anyways.
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#137Earlier quoted context omitted.
Sorry, I didn't feel like this thread needed to be dragged out any longer since it's going in circles at this point and expanded my comment, but I didn't realize you had already replied.
Well - not really a circle. I keep saying the same thing over and over and you keep throwing arguments at it, unsuccessfully.
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#138the zero terminated string is I think is computing's biggest mistake. Pascal style strings were much safer.
Clang and GCC both let you use Pascal strings in C if you would like (with `\p`). But Pascal strings aren't that useful today because the maximum length is too short.
A C string is one pointer reaching all of memory, a Pascal string is two pointers reaching all of memory
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#139the zero terminated string is I think is computing's biggest mistake. Pascal style strings were much safer.
Zero terminated strings were the basis for an awful lot of useful software. Calling them the biggest mistake in computing is a bit OTT. I haven’t programmed anything Pascal related for 30+ years but I dimly remember thinking at the time that I wished the string system wasn’t so hard to use.
* https://news.ycombinator.com/item?id=48614913
Re: Linux eliminates the strncpy API after six years of work, 360 patches
#140You know who did have the right idea though? Dennis Ritchie, who proposed a fat pointer type for C all the way back in 1990. Would have made for a perfect addition to C99. Imagine how different the world might have been had the committee added that in.
We had a second chance with the release of the "C's greatest mistake" blog article from Walter Bright in 2007, essentially pushing for the same idea as Ritchie (slices/stringviews) but explained with much clearer language.
Alas, didn't make it to C11.
We're now in C23, still nothing. But we did get _Generic and VLAs! Party hard.