r/cprogramming • • Aug 17 '26

C Strings: A 50-Year Mistake

https://longtran2904.substack.com/p/c-strings-a-50-year-mistake?r=8qz2zb&utm_campaign=post&utm_medium=web
212 Upvotes

172 comments sorted by

View all comments

Show parent comment

-1

u/flying-sheep Aug 18 '26

They're not foundational. You know what's foundational? Fixed size arrays in the executable, fixed sized arrays on the stack, and heap pointers + length. These are all just as perfectly suited for strings as they are for other collections.

C style strings made sense for 16 bit systems, but not a minute later.

1

u/bearheart Aug 18 '26

Foundational means it's the foundation of other structures. All string libraries in C and C++ use C-strings under the hood.

0

u/flying-sheep Aug 18 '26

Yeah that’s exactly what I mean: it doesn’t serve as an acceptable foundation. The article points out some ways in which the arising APIs are inflexible (e.g. you can’t just use array APIs), clunky (off-by-one errors), and so on.

A good foundation would just be slices (implemented on many platforms as fat pointers)