Live data from Hacker News

C’s Biggest Mistake (2009)

digitalmars.com

141–150 of 382 posts

Re: C’s Biggest Mistake (2009)

#141

Unfortunately working with dynamically-allocated buffers is still a thing; adding array syntax just favors one form of size specification without solving the other case. Although C is usable on many types of hardware, interesting things could be done, e.g. on desktop OSes if certain hardware-specific extensions were made. One of the things I wish we could do with our now-absurdly-large pointers (64-bit) is to reserve…

> Unfortunately working with dynamically-allocated buffers is still a thing; adding array syntax just favors one form of size specification without solving the other case. All that is needed is a mechanism for forming a fat pointer from a pointer and a length. In D this looks like: int* p = cast(int*)malloc(length * sizeof(int)); if (!p) fatalError(); int[] a = p[0 .. length]; ... int x = a[length + 1]; // runtime er…

Tongue in cheek: I already have a fat-pointer:

    struct foo {
        int a[10];
    } f;

    func(&f);

Re: C’s Biggest Mistake (2009)

#142

Author 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.

It simply impossible for C to finish or vanish. It is one of the most tested and rock solid pillar in programming world. Developers already mastered how to handle the issues you mentioned in article. They are not such big to discard C.

Re: C’s Biggest Mistake (2009)

#143
post #119
post #36

Earlier quoted context omitted.

All of this I agree with. In a better world 'arrays' would have added in the 1980's. The arguments about memory limitations is spurious since if you're writing good code you always pass a pointer and the length. Always no exceptions. Yeah and all the string functions should have been marked as depreciated with C89 and fully depreciated with C99.

Yes, you can always pass a pointer and a length explicitly. And that's what the "safe" versions of e.g. string functions do. But it's still incumbent on you as the programmer to use them properly. It would still be beneficial to have a compiler mode where all that was done for you automatically and it was impossible to have a buffer overrun.

The safe string functions aren't safe because they don't return safe strings.

Re: C’s Biggest Mistake (2009)

#144
post #102
post #27

Earlier quoted context omitted.

Unfortunely until we get rid of UNIX/POSIX clones, C will be kept around. So not in my lifetime.

Or at least not in Torvalds' lifetime. His views on replacements for C are legendary. It would be interesting to see his comments on this proposal.

[deleted]

Re: C’s Biggest Mistake (2009)

#145

Earlier quoted context omitted.

Pro tip: Google the name of the person before responding to them, it can help avoid the taste of foot in your mouth which you are currently experiencing.

Anyone that has to rely on their name for an argument isn't worth listening to.

You misunderstand what the conversation is that’s occurring. The parent implied the person had never written C.

Re: C’s Biggest Mistake (2009)

#146

Earlier quoted context omitted.

Anyone that has to rely on their name for an argument isn't worth listening to.

You misunderstand what the conversation is that’s occurring. The parent implied the person had never written C.

He never said explicitly, he was just making a general statement. Not that it matters whether he did or didn't, there's a lot of things wrong with C, it will most likely eventually disappear, but not for reasons outlined in this article. That's what he was saying.

Re: C’s Biggest Mistake (2009)

#147
post #54

Earlier quoted context omitted.

"C is finished if it doesn't address the buffer overflow problem" You should keep making this prediction ... one day you might be right! :)

C code is being replaced by Rust fast. The only limit is how quickly programmers can become good at Rust. It's already happening.

> C code is being replaced by Rust fast. The only limit is how quickly programmers can become good at Rust. It's already happening.

I think Rust has been very quickly fading into obscurity. What Rust hast brought to the tables was nearly the same what was brought by 100+ other programming languages in attempts to "fix C."

Re: C’s Biggest Mistake (2009)

#149
I’ve been writing C code for 30 years. What I like about it is code from back then is pretty much similar to what you’d right today so there’s limited need to chase the train. Sure it has security issues but if you don things ‘right’ it’s still untouchable, imo. Most other languages are heavy and slow compared to C. A lot are not even backwardly compatible (python) or suffer from being kitchen sinks (C++). My own opinion is that python is the only other ‘must know’ language as you can do RAD. For speed you resort to C. There are so many toy languages in between with some nice features (coroutines, native JSOn support, etc). But lots are just meh. All personal opinions.

Re: C’s Biggest Mistake (2009)

#150

I’ve been writing C code for 30 years. What I like about it is code from back then is pretty much similar to what you’d right today so there’s limited need to chase the train. Sure it has security issues but if you don things ‘right’ it’s still untouchable, imo. Most other languages are heavy and slow compared to C. A lot are not even backwardly compatible (python) or suffer from being kitchen sinks (C++). My own opi…

Have you ever tried nim?
Post reply on HN