Live data from Hacker News

Linux eliminates the strncpy API after six years of work, 360 patches

phoronix.com

171–180 of 340 posts

Re: Linux eliminates the strncpy API after six years of work, 360 patches

#171

the zero terminated string is I think is computing's biggest mistake. Pascal style strings were much safer.

There is a middle ground that Visual Basic (and then COM) took, with the BSTR type: It’s still a pointer to a zero-terminated char array, but there is a length field immediately preceding the first pointed-to byte. This is still compatible with a C string (assuming no embedded null characters), but BSTR-typed functions can take advantage of the length value.

Re: Linux eliminates the strncpy API after six years of work, 360 patches

#172
post #166

In all the comments in this thread it's interesting how people confuse: * NUL: An ASCII non-printing character with the byte value of 0 * NULL: A pointer that does not point to usable memory with the value that compiles in C to be equal to ((void *) 0).

NUL was always just an abbreviation for null: https://www.rfc-editor.org/rfc/rfc20.html#section-4

I don’t think anyone in this thread is confusing the null character with the null pointer.

Re: Linux eliminates the strncpy API after six years of work, 360 patches

#173
post #170
post #118

Earlier quoted context omitted.

Today yes, but 40 years ago someone made the decision that a string was a char array and that every string manipulation going forward would require manipulating arrays. Talking about costly decisions. It’s actually interesting to compare the pain and suffering of switching to a string datatype in the 80s (refactoring the limited code base then) vs the next 40 years of unnecessary boiler plate syntax and bugs for not…

The decision was made almost 55 years ago for C and Unix: https://en.wikipedia.org/wiki/Null-terminated_string#History

around the same time Wirth decided to have a length prefix in his Pascal strings (that's why string adressing began at 1, because 0 would be the length of the string)

Re: Linux eliminates the strncpy API after six years of work, 360 patches

#174
post #45

Earlier quoted context omitted.

Well, not saying to always use it, but if the string size is big enough, the overhead of 2 ints becomes relatively vanishing. For generic dynamically sized strings it probably has more advantages than disadvantages. But in any case, sure, if every single byte matters or some structure requires specific memory layout, then fine. I just don't think these things are the majority of use cases. Keep in mind that the cache…

> Well, not saying to always use it, but if the string size is big enough, the overhead of 2 ints becomes relatively vanishing. In that case, the fix is not to change C strings (breaking a lot of existing code), but to introduce a stringbuilder type.

You can still use null terminator for compatibility (std::string does use this), but just not rely on that in your own code.

Re: Linux eliminates the strncpy API after six years of work, 360 patches

#175
post #84
post #69

Am I going to be the first person to ask this after five hours? Really? Wouldn't this work be extremely easy to implement with an LLM coder?

I don't think the bottleneck was that it took six years to Ctrl-F strncpy and type in new code for each file.

[flagged]

Re: Linux eliminates the strncpy API after six years of work, 360 patches

#176
post #86
post #84

Earlier quoted context omitted.

I don't think the bottleneck was that it took six years to Ctrl-F strncpy and type in new code for each file.

It's a shame you're misrepresenting what is actually going on. In another comment here I explained that I have run a test: asking Claude Code to add a substantial feature to 270 different C programs. Despite your beliefs - it went extremely well.

> In another comment here I explained that I have run a test: asking Claude Code to add a substantial feature to 270 different C programs.

That's a different scenario, though.

Would Claude have performed adequately if it had to add a specific feature to 270 programs buried in a set of 270m program, each of which may or may not have a dependency on one or more of the others, with virtually unbounded results to test?

In terms of tokens alone, that would have been cost-prohibitive. But lets assume that you had the money to do this: it still might not even be possible.

You're confusing "I have these 270 independent programs and want to make this change to all of them" with "I have these 270m lines of code, of which only 270 needs to be changed".

Re: Linux eliminates the strncpy API after six years of work, 360 patches

#177

Earlier quoted context omitted.

Sum types, of course.

How do you expect to use sum types in assembly? Remember where C came from and why it was designed the way it was.

I remember why C stayed what it is at least: elitism and gatekeeping. And YAGNI, repeated millions of times, of which only the first few were correct.

You're telling me OCaml / Rust / Haskell compile to fairy pixie dust? Obviously their compilers figured it out and it works.

Re: Linux eliminates the strncpy API after six years of work, 360 patches

#178

Earlier quoted context omitted.

Sum types, of course.

How are you going to build sum types in a way where you can interact with assembly or machine code? The CPU doesn't know about that stuff

OCaml / Rust / Haskell.

Apparently they found a way to have the CPU know... about "this stuff".

Re: Linux eliminates the strncpy API after six years of work, 360 patches

#179
post #172
post #166

In all the comments in this thread it's interesting how people confuse: * NUL: An ASCII non-printing character with the byte value of 0 * NULL: A pointer that does not point to usable memory with the value that compiles in C to be equal to ((void *) 0).

NUL was always just an abbreviation for null: https://www.rfc-editor.org/rfc/rfc20.html#section-4 I don’t think anyone in this thread is confusing the null character with the null pointer.

I've seen a lot of confusion, where people are talking about checking for a NULL at the end of a list of pointers which is very different to a NUL at the end of a string.

Yes it was an abbreviation in ASCII, as are all the non-printable first 32 codes.

Re: Linux eliminates the strncpy API after six years of work, 360 patches

#180
post #161

Earlier quoted context omitted.

So what exactly is the NUL/0 in the code below other than a sentinel value? while (*d++ = *s++) ;

I am not sure what this is in response to. Can you explain which point of mine you are responding to?

> If the hardware had instructions for sentinel values, things would be easier (Like how DOS calls used '$' termination for strings) and safer.

A zero is a sentinel value and is catered to by all ISAs.

Why would using a "$" be any easier/safer than a NUL?

Post reply on HN