r/ProgrammingLanguages • u/funcieq • May 23 '26
Discussion How to implement String?
Currently, String in my language is just value and length because it's a temporary solution, And as the language has developed, I am now able to rewrite a lot just for it, so I want to make a decent String in my language. So my question is, which String concept annoys you the least?
47
Upvotes
View all comments
Show parent comment
6
u/Kiore-NZ May 23 '26
In c++, std::string_view is very easy to create. My simplistic strings implementation does it like this
data() just returns const char * pointing at the string & len() return a character count.
Going the other way requires a constructor that takes the values returned by the string_view's .begin() & either .length() or .end() methods.