Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not sure I agree with "impossible to change".

It's 2026, to this date I cannot use standard library/api, to open a file with utf-8 filename without a null terminating string.

When you want to talk to the OS you constantly face the need to had unnecessary overhead (allocation due to string convertion, strlen).

The OS itself does not prevent anything from having those standard "no overhead" API.

However, it's pretty clear that nobody cares to define some new sane interface and nobody care to deprecate old ones.

That would include both API and ABI.

 help



Maybe because the performance gain is just not there. Adding support for string with explicit length everywhere is a huge amount of work. And then the question is whether such a string is like a Rust slice or something else.

And then the gain is close to zero because most filenames are short enough that there is almost no gain.


The mental overhead is pretty significant.

You need to do weird string operations, you have certainly a class somewhere that needs to append a zero to then end of a buffer, and exclusively use the class for thw filename. You can't just toss a contiguous number of bytes you to convert it first.

Every single piece of software that need to interact with the file system needs to deal with this.

I'm not asking about a new string type. I'm asking to be able to be free from null terminating string.

You only need to provide a length.


In practice, with Rust the problem is somewhere else. There is a libc crate that wraps the Unix system calls, so no need to worry about that. What is a lot harder is that Unix filenames are not guaranteed to be UTF-8. So you can't convert to &str or String. At least, not without loss. So you have to keep this around as an OsString.

Yeah that's the kind of thing I'm talking about.

Even when you don't care about being cross-platform, you still need to rely on specific routines instead of having the most low level `ut8fopen(buffer, len, mode);`

My point is that I wish we would have a new "standard OS-related API", not even talking about introducing span type or anything, just creating something way more sane and care about moving forward from this point.

If I was about to create my own OS and decided to eliminate null-terminating string, and keep it as tiny and efficient as possible, I would face so many issues because I cannot reuse 99% of the code (related to file API) that already exists, I would need to think how to properly parse arguments from "main" without overhead etc.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: