News for hackers. Stuff that matters.
Re:I write games in C (yes, C) by uecker on Saturday February 07, 2026 @05:17PM (#46928726)
Sure, but you can have a similar string abstraction in C. What would you miss? The overloaded operators?
Re:I write games in C (yes, C) by direwolf20 on Saturday February 07, 2026 @07:31PM (#46929951)
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
Re:I write games in C (yes, C) by uecker on Sunday February 08, 2026 @01:37AM (#46931860)
This seems orthogonal to std::string. People who pick C do not want automatic memory management, but might want better strings.
Re:I write games in C (yes, C) by direwolf20 on Sunday February 08, 2026 @05:01AM (#46932933)
Automatic memory management is literally what makes them better
Re:I write games in C (yes, C) by uecker on Sunday February 08, 2026 @05:53AM (#46933187)
For 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).
Re:I write games in C (yes, C) by direwolf20 on Sunday February 08, 2026 @11:11AM (#46935562)
You 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.
Re:I write games in C (yes, C) by uecker on Sunday February 08, 2026 @11:44AM (#46935973)
Yes, 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.
Re:I write games in C (yes, C) by direwolf20 on Sunday February 08, 2026 @05:37PM (#46939290)
Empirically it is. All the most used languages are the most convenient ones.