5 ms·
Null terminated strings are often called cstrings. They’re beyond idiomatic; they’re part of the C standard library.
by rcoveson 6y ago
Null terminated strings are often called cstrings. They’re beyond idiomatic; they’re part of the C standard library.
- lambda 6y agoNot just the standard library, but the core language. They are what you get if you write a string literal in your code.
- jacoblambda 6y agoYes but if we are being pedantic no. Of course the language does still greatly lean into the null terminated string concept. You get a null terminated char array but the length is actually available since arrays (as long as they haven't decayed into pointers) can still share their length at compile time.
- akkartik 6y agoAlso Unix. Syscalls return null-terminated strings all over the place. So any language running on Unix has to deal with null-terminated strings. I know because I run a userland that uses length-prefixed strings as far as possible: https://github.com/akkartik/mu https://github.com/akkartik/mu
- michaelmior 6y agoTrue. I was skipping over that, but the fact that functions manipulating null terminated strings are part of the standard library is certainly a reason in itself to consider them idiomatic.
- akkartik 6y agoThey're agreeing with you.
- michaelmior 6y agoYes, I understand :)