Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

Of course, for now. But I still disagree that it is as easy (or hard) to write C without bugs as in any other languages. Most people should not write C.


sort by: page size:

You're free to write bugs in any language. C just makes them easier to write or more critical.

No, because C compilers are no longer as buggy as they used to be.

C is okay except safety. Look at the CVE lists and they are still full of memory errors and it’s 2024.

The problem isn’t that good programmers can’t write good C code, though anyone can make a mistake. The problem is what happens as code ages, is worked on by other people, gets PRs merged, and so on. Bugs creep in and in an unsafe language nothing catches them.

C also makes string processing hellish, but that could be fixed with libraries and isn’t necessarily the fault of the language.


Agree and in C you still have all the bugs of the type that you describe for Java or whatever...

It just there is a lot of C out there which means we will see it for ever in our systems somewhere. It will get better over time as tools improve the existing C code base.


To write C is to code bugs. So, pick a different language.

It's probably an accurate comparison, given the amount of code out there that really doesn't need to be written in C, but nevertheless it is (and the majority of people writing it aren't capable of writing bug-free C).

Yes. I enjoy writing C and as long as it does not face the internet and does not handle that much untrusted input I will just use it.

I frankly haven't found an ecosystem in which I feel more comfortable than the one from C.

Yes, C has its vulnerabilities, but for my own projects I do in my own time, I will use any language I have fun with, even if it has huge problems.


I didn’t make a claim about C being “so bad”, because it really isn’t “so bad”.

My only claim is with respect to maintenance; namely that C in and of itself is not a language that enforces maintenance and good practices out of the box.

The chain of causality is the opposite. Good projects survive because of good practices, not because of C, and they’d have survived in any other language; just like all other software that has survived.

That’s the only claim that I am making. That, and that compiler enforced soundness makes software more enjoyable to build.


I like C, maybe it is Good Enough, but don't you think C has some real flaws that could be fixed in a newer language?

Nobody writing in C has "bug free" as their highest priority. Reducing dependencies is good though.

While C is not perfect, it is in a sense something that most other programming languages are not. It's simple and if you program in C you probably touch upon the entirety of the language on a regular basis. Because it is simple you can write a compiler for it with some reasonable effort if need be, even for completely new architectures.

In any case, I'd argue that most of the quirks are due to undefined behaviour as implemented in the compilers. And 50 years from now the language have probably evolved some more anyway.


I respectfully disagree. I think C is a giant disaster that will continue to plague us entirely due to inertia. You're really underestimating how entrenched it is. Try to go program on micro in something other than C. Try programming a driver. The toolchains simply don't exist - the comparability with several decades of work is also shaky.

C is a terrible cross platform assembly b/c it doesn't allow you the level of control which one would expect in this day and age. Maybe it was written in the days when CPUs were brain-dead simple, but basic things that are available on most architectures aren't part of the language. It has no notion of a CPU cache, it has no notion of branching (you can't tag a likely branch and an unlikely one), it even goes as far as to ignore user keywords for inlining and provides no keyword for blocking inlining. RVO is implicit magic that you just pray happens. Const != immutability.

When you write C you have no notion of what the compiler is going to output whatsoever

A lot of these things are available through compiler extensions (so great, now it's not cross-platform), but even still the language is broken. "Expert C Programming" has a really long chapter that goes over all the more confusing subtly problems C has beyond just arrays being pointers-but-not-really.

I have to use C pretty regularly and all I can think is "God.. why hasn't anyone made this better yet"


C really is a great language, its kinda funny how all the attempts to improve on it end up causing just as many pain points as they solve.

Developing robust programs in C just requires a clear understanding of the language itself (and of course a good overall skill set as a programmer). I have been writing (mostly) bug-free code in C for over twenty years. My only real complaint is that it forces you to write lots of "boilerplate". Beyond that, it is a fine language for systems programming (provided you know what you are doing). I have had many more issues working with scripting languages (I'm lookin' at you, Java and Ruby!) where the bugs existed not in my program, but in the VM itself. Having said that, I do enjoy working with higher-level abstractions.

Sooner or later we're going to have to accept that C family languages are fundamentally broken and unsafe at any speed for new development.

I'd disagree about C. It is just too simple to look like something deliberately created to write unmaintainable code. Although we know it is not only possible, but actually common.

not denying there are issues... just saying that C isn't the only widespread language with issues. at least C's problems are widely known.

C doesn't have any problems just because you use it poorly. The only thing with a problem would be the coder.

I can't wait for the time when it isn't considered ok to use languages that are so error-prone. I wouldn't write anything in C.
next

Legal | privacy