| ▲ | masklinn 19 hours ago | |||||||||||||
We have. C is basically the only langage in any sort of widespread use where terminated strings are a thing. Which of course causes issues when languages with more proper strings interact with C but there you go. | ||||||||||||||
| ▲ | saghm 14 hours ago | parent | next [-] | |||||||||||||
Given that the C ABI is basically the standard for how arbitrary languages interact, I wouldn't characterize all of the headaches this can cause as just when other languages interact with C; arguably it can come up when any two languages interact at all, even if neither are C. | ||||||||||||||
| ||||||||||||||
| ▲ | thayne 18 hours ago | parent | prev | next [-] | |||||||||||||
We should move away from it in C usage as well. Ideally, the standard would include a type that packages a string with its length, and had functions that used that type and/or took the length as an argument. But even without that it is possible avoid using null terminated strings in a lot of places. | ||||||||||||||
| ||||||||||||||
| ▲ | throwaway2037 3 hours ago | parent | prev | next [-] | |||||||||||||
Doesn't C++'s std::string also use a null terminated char* string internally? Do you count that also? | ||||||||||||||
| ||||||||||||||
| ▲ | ofalkaed 4 hours ago | parent | prev [-] | |||||||||||||
>Which of course causes issues when languages with more proper strings interact with C but there you go. Is is an issue of "more proper strings" or just languages trying to have their cake and eat it too? have their sense of a string and C interoperability. I think this is were we see the strength of Zig, it's strings are designed around and extend the C idea of string instead of just saying our way is better and we are just going to blame C for any friction. My standard disclaimer comes into play here, I am not a programmer and very much a humanities sort, I could be completely missing what is obvious. Just trying to understand better. Edit: That was not quite right, Zig has its string literal for C compatibility. There is something I am missing here in my understanding of strings in the broader sense. | ||||||||||||||