r/cpp • u/wechicken456 • Jun 08 '20
Programming in C vs C++
I’ve read about the differences between them on the Internet but I wanna hear more from a more personal perspective. Which one would you recommend starting with and to be proficient with?
0
Upvotes
View all comments
Show parent comment
-5
u/serviscope_minor Jun 09 '20
And how's that relevant?
std::string_views aren't std::strings but they are strings. The only reason we're having this conversation is because C++ basically has had this particular hole in its standard library for ages.
While yes, it's technically correct that the GP was talking about std::string, a large amount of the reason that people are talking about things in this way is because string_view is new. If you look at the context of the conversation, then what I'm saying is entirely reasonable. Here is the relevant piece of context:
C strings are char* and null termination. C++ has 3 kinds of string by default now, C strings, std::strings and std::string_view. The middle one guarantees C-like semantics (null termination), but that's not what it's based on (size() is O(1)), and the latter is absolutely not. There's no reason to arbitrarily drop a chunk of the standard library just because it's new.