|
|
|
|
|
by sirwhinesalot
5 days ago
|
|
I have in the past made fun of the Linux kernel devs, supposedly some of the best C developers in the world, for not knowing how to make stringbuffer and stringview types, but to be fair to them we didn't have the consensus we have today on the topic. You know who did have the right idea though? Dennis Ritchie, who proposed a fat pointer type for C all the way back in 1990. Would have made for a perfect addition to C99. Imagine how different the world might have been had the committee added that in. We had a second chance with the release of the "C's greatest mistake" blog article from Walter Bright in 2007, essentially pushing for the same idea as Ritchie (slices/stringviews) but explained with much clearer language. Alas, didn't make it to C11. We're now in C23, still nothing. But we did get _Generic and VLAs! Party hard. |
|
https://digitalmars.com/articles/C-biggest-mistake.html
And because it came up in my search and the bikeshedding discussion made me chuckle, reddit on same: https://www.reddit.com/r/C_Programming/comments/90uq7c/cs_bi...
Am curious about this esoterica, if anyone can confirm/deny:
>> Speaking of [C] arrays decaying into pointers, does anyone know why this behaviour was designed in the first place?
>> It was so that B code could be compiled as C with minimal changes. The designer felt that this would encourage people to switch from B to C. In B an array declaration actually defined a pointer and an array, with the pointer initialized to point to the array's first element.