Earlier quoted context omitted.
A question: since your company also makes a C/C++ compiler (and the repo has very :), have you considered adding this addition to it, as an experimental feature, perhaps to demonstrate its usefulness to other developers and standard bodies? (Although, now that I think of it, D itself might serve the same purpose)
I don't see much point in it. I've proposed this change to C in front of several audiences, and it never received any traction. If you want to experiment with it, you can use DasBetterC, i.e. running the D compiler with the `-betterC` switch, which enables programs to be built requiring only the C Standard Library. Fair warning - once you get accustomed to DasBetterC, you're not likely to want to go back to C :-)
C’s Biggest Mistake (2009)
221–230 of 382 posts
Re: C’s Biggest Mistake (2009)
#222Author 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.
The proposal is just syntactic sugar for an size argument. It doean't add or solve anything really.
Yes, it's not a lot of effort to manually add a size_t argument. But it is far too tedious and error-prone to expect a programmer to add all the bounds checks. Being able to effortlessly tell the compiler "please check for me" is the huge win.
The second huge win is that the array is type-checked. So if you pass it to another function, the compiler enforces that it must again be passed with the size included. You don't get that by manually adding a size argument.
Re: C’s Biggest Mistake (2009)
#223Earlier quoted context omitted.
Do they? Or are they just told that they should be using Rust? Even putting aside outdated curriculum, Rust is a fairly involved language to teach to a new programmer.
Indeed. What languages are most common in universities anyways? Haskell? Java? C++? OCaml? Which ones are the most common? Maybe he meant outside of the education system. I think the reason for that would be hype and peer pressure, and the feeling of novelty, with a hint of FOMO. I do not see any languages being pushed/hyped as hard as Rust.
That is a mighty good showing for C.
Re: C’s Biggest Mistake (2009)
#224There are actually two problems here. One is the absence of bounds checking. The other, which is related but technically orthogonal, is the hole in the type system: an array is not an object. It's been true since Unix v7 that you can pass or return a struct by value, but you can't pass an array by value unless you wrap it in a struct.
The type system also makes no distinction between a pointer to a single object and a pointer into an array of objects. I've worked on static analysis tools that try to find potential buffer overflows, and this turns out to be a surprisingly big problem. One has to do a global dataflow analysis just to discover which pointer variables could ever point at array elements.
Re: C’s Biggest Mistake (2009)
#225Earlier quoted context omitted.
I suspect C has been steadily losing ground since I made it.
It's been 11 years, and C is running on more hardware than it ever has before, viz every android device. By what measure would C be losing ground?
Nobody would do a project in C today with Go/Rust/C++ etc unless it's for a very specific situation
Re: C’s Biggest Mistake (2009)
#226Earlier quoted context omitted.
Ok, but you didn't just say this should be possible, you said it should be the default best-practice . Even if it were useful in a handful of cases, this would be a terrible default way of doing things.
I didn't say it should be the default, but yes it should be. It is for structs. We can have giant structs. I've seen some over a megabyte in size. The default is that the callee gets a copy. (depending on the ABI it could be in the "wrong" stack frame, but it is a distinct copy) Are we having huge problems with structs being passed by value? I don't think so. Normal people pass pointers, except when they actually wan…
Re: C’s Biggest Mistake (2009)
#227Earlier quoted context omitted.
> One of the niceties of C is that I can get anything done pretty damn quickly, without anything getting in my way. not saying you're necessarily wrong (c is definitely simpler than rust), but I think most people would write a similar comment for whatever language they feel most comfortable with. I write c++ most days. even though it's the most verbose and complicated language I've ever used, I can still probably get…
Agreed - in that I write it in Perl if I need it to just work right now. Perl is still, to me, the most useful programming language for completing a generic program in the smallest amount of time. (Part of that is due to CPAN, and part to the gazillion built-in features of Perl 5)
I don’t go out of my way to teach or suggest Perl to my younger colleagues. I don’t know why that is. They don’t usually reach for Python, which I think would probably be their best choice.
Maybe I’m just a curmudgeon ... and by the way, can you please stay off my lawn?
:)
Re: C’s Biggest Mistake (2009)
#228Author 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.
The proposal is just syntactic sugar for an size argument. It doean't add or solve anything really.
So those programmers might just use the sugared approach and avoid the problem of writing past the end of an array, without ever knowing how tedious and/or difficult debugging such problems can be. They might sort of never even realize that they dodged a bullet simply due to some sugar.
How do you see it?
Re: C’s Biggest Mistake (2009)
#229Earlier quoted context omitted.
I suspect C has been steadily losing ground since I made it.
It's been 11 years, and C is running on more hardware than it ever has before, viz every android device. By what measure would C be losing ground?
And the history of Linux kernel and Android might come to an end if Zirkon ever replaces it, then it will be no more C on Android.
Re: C’s Biggest Mistake (2009)
#230Earlier quoted context omitted.
It's been 11 years, and C is running on more hardware than it ever has before, viz every android device. By what measure would C be losing ground?
> By what measure would C be losing ground? When we start seeing Rust or similar being used instead of C would be a good metric and / or major OS development.