by nicoburns · 5y ago · 0 comments
I first encountered that idea in this classic Joel on Software post, which rather put me off the idea of using them in production:
> Notice in this case you’ve got a string that is null terminated (the compiler did that) as well as a Pascal string. I used to call these fucked strings because it’s easier than calling them null terminated pascal strings but this is a rated-G channel so you will have use the longer name.
> Lazy programmers would do this, and have slow programs
char* str = "*Hello!";
str[0] = strlen(str) - 1;
Modern compilers understand strlen, and will replace the function call with a constant where possible. That code's not slow anymore: https://godbolt.org/z/Kjh8b44KfBut Joel was talking about C rather than C++, where your comments about std::string wouldn't apply, right?