3 ms·
Automatic memory accounting — construct/copy/destruct. You can't abstract these in C. You always have to call i_copied_the_string(&string) after copying the str
by direwolf20 9mo ago
Automatic memory accounting — construct/copy/destruct. You can't abstract these in C. You always have to call i_copied_the_string(&string) after copying the string and you always have to call the_string_is_out_of_scope_now(&string) just before it goes out of scope
- uecker 9mo agoThis seems orthogonal to std::string. People who pick C do not want automatic memory management, but might want better strings.
- direwolf20 9mo agoAutomatic memory management is literally what makes them better
- uecker 9mo agoFor many string operations such as appending, inserting, overwriting etc. the memory management can be made automatic as well in C, and I think this is the main advantage. Just automatic free at scope end does not work (without extensions).
- direwolf20 9mo agoYou can make strings (or bignums or matrices) more convenient than the C default but you can never make them as convenient as ints, while in C++ you can.
- uecker 9mo agoYes, but I do not think this is a good thing. A programming language has to fulfill many requirements, and convenience for the programmer is not the most important.
- direwolf20 9mo agoEmpirically it is. All the most used languages are the most convenient ones.