Earlier quoted context omitted.
I use stb myself, so I have no qualms with that. The point is rather that GP was discussing praise for C’s standard library, and even the most portable single-file include-only dependency remains just that: an external dependency that isn’t part of the C standard library (and no, posix isn’t C).
Does it make much of a difference though? Take the hyped Rust for example. Most useful stuff is in crates, i.e. an external dependency. No one seems to have a problem with that. Personally I do not mind using libraries typically installed by the Linux distribution's package manager anyways. If the question is whether or not I think the C standard library could be improved, then yes, I would say it could, but I do not…
C’s Biggest Mistake (2009)
341–350 of 382 posts
Re: C’s Biggest Mistake (2009)
#342Author here. I'll be blunt and repeat a prediction I made 3 years ago or so: C is finished if it doesn't address the buffer overflow problem, and this proposal is a simple, easy, backwards compatible way to do it. It is simply too expensive to deal with buffer overflow bugs anymore. This one addition will revolutionize C programming like adding function prototypes did.
Walter, I honestly just can't trust your judgement on the future of C or C++, because all I ever see is you pushing D anytime you comment. This seems like just another gimmick to push D tbh.
Re: C’s Biggest Mistake (2009)
#343Earlier quoted context omitted.
Maybe dial back the sarcasm a notch or two?
Many apologies - I was not being sarcastic and I'm sorry that this is how my comment came across. As chongli says I'm a native speaker of Greek and I really didn't know how "eso" is pronounced by native English speakers. I've lived for 15 years in the UK and I'm still surprised to hear how people pronounce the more obscure words in their language (some of which come from Greek).
Re: C’s Biggest Mistake (2009)
#344Re: C’s Biggest Mistake (2009)
#345Earlier quoted context omitted.
C has been "losing ground" not because of random per peeves of those who never wrote a line of code in C but because since C's last standard update there have been other programming languages that offer developers something of value so that the trade-off between using C or any alternative starts to make technical sense. It also helps that C's standardization proceeds in ways that feel somewhat between sabotage and ut…
Maybe people are voting this down because they think it's directed at Walter Bright in particular, but I think there is actually some truth in the harsh comment. Nothing about Walter Bright in this statement, but some of the harshest criticisms from others I have seen of C are not from expert practitioners in C. People who are experts and also critics seem to have a more practical, realistic, nuanced critique, that u…
Re: C’s Biggest Mistake (2009)
#346Earlier quoted context omitted.
The real troubles are undefined behavior and aliasing. Buffer overflows are just a well known gimmick of the language that is more or less controllable with some discipline. Aliasing is hell. You cannot even use a global variable safely!
> You cannot even use a global variable safely! Sorry? I’m unsure what you mean here, because there are plenty of ways to use globals in ways I would call “safe”: no undefined behavior, correct output, …
int x;
and in another: int* x;
and you'll be mixing pointers and ints and it won't be detected.Re: C’s Biggest Mistake (2009)
#347Author here. I'll be blunt and repeat a prediction I made 3 years ago or so: C is finished if it doesn't address the buffer overflow problem, and this proposal is a simple, easy, backwards compatible way to do it. It is simply too expensive to deal with buffer overflow bugs anymore. This one addition will revolutionize C programming like adding function prototypes did.
Walter, I honestly just can't trust your judgement on the future of C or C++, because all I ever see is you pushing D anytime you comment. This seems like just another gimmick to push D tbh.
1. the judgement of people in the industry, who will always be biased
2. the judgement of people not in the industry, who don't know what they're talking about
As for me, I still sell a C and C++ compiler https://www.digitalmars.com/shop.html
Re: C’s Biggest Mistake (2009)
#348Earlier quoted context omitted.
Not constexpr, this is solved by constant generics (the famous RFC 2000) with the array bound as a constant “generic” parameter/value. I’ve been pushing for this feature for many years and have been playing with it since it first landed in nightly. It works quite well.
Sorry, I misspoke. But this wasn't meant to be about Rust. My point was that: if you dump slices/fat pointers into C, how does it help? Slices/fat pointers and the corresponding checks are a runtime thing, and that's absolutely anathema to a lot of C programmers. If it's not anathema to the C programmer, they probably aren't in C anyway. So, now you need a way so that compiled slices/fat pointers mean something, and…
Most people using D leave the checks on.
Even without the checks, however, I can vouch that implicitly carrying around the length of the array with the array pointer is a vast improvement in the clarity of the written code.
Re: C’s Biggest Mistake (2009)
#349Earlier quoted context omitted.
I'm not sure whom this proposal is aimed at exactly. Any production-quality C code will already use a (pointer + count) combo when passing arrays to a function, which is something that will still be needed under your proposal because the vast majority of arrays is dynamically sized. So unless all arrays in C are given the fat pointer treatment, I don't really see how what you suggest would make much of a difference.…
pointer + size does not really fix anything, as you are relying on the programmer to correctly keep track of the size. I'm not even sure what alternative this improves upon. even more error-prone null value marking the end? praying the array will be big enough (looking at you, gets!)? unless you have a team of incredibly diligent coders, people are going to read past the end of bare arrays over and over again. one sp…
Quite right. I use, and highly recommend, the convention that `size` is for number of bytes, `length` is for number of elements, and `capacity` for the allocated number of elements.
assert(length * sizeof(element) == size);
assert(length Re: C’s Biggest Mistake (2009)
#350Earlier quoted context omitted.
pointer + size does not really fix anything, as you are relying on the programmer to correctly keep track of the size. I'm not even sure what alternative this improves upon. even more error-prone null value marking the end? praying the array will be big enough (looking at you, gets!)? unless you have a team of incredibly diligent coders, people are going to read past the end of bare arrays over and over again. one sp…
Would you just wrap the pointer and size in a strut, then only iterate the array via a library of functions that check the size first? I don't code c full time, but it's what I have always done when needing to use c via ffi to get a speed up in a dynamic language.