4 ms·
"If you are not using modern tools like valgrind/coverity/whatever, you are not comparing C fairly to contemporary languages." I personally consider C + strong
by jerf 10y ago
"If you are not using modern tools like valgrind/coverity/whatever, you are not comparing C fairly to contemporary languages."
I personally consider C + strong static analysis tools to be an entirely different language. I fully acknowledge this is my personal opinion.
Consequently, I consider it equivocation in this sort of context to be talking about C when convenient, then talk about C + strong static analysis tools when convenient. You're only programming in one or the other. My utter contempt is for C the language by itself. This is relevant because as near as I can tell, C has at least a 10:1 advantage in the field over C + strong analysis tools, and I'm probably off by at least a factor of magnitude. It is not realistic to pretend that C programmers are using these tools at scale. (Now, you can point at a ton of high profile C programs that do use these tools, because high profile C programs are exactly where they get used. But as near as I can tell they are firmly the exceptions, not the rule. And you can point at a ton of high-profile projects that don't use them, too.)
If everybody started using all these tools, including the ones that you actually have to buy because there's no open source equivalent of, it is true that most of my issues with C would be resolved. It would also be true that programmers would be a lot less gung-ho about C, though, because as anyone who has deeply integrated these strong tools into their workflow can attest, C + strong analysis tools is a much more complicated language. Now, in my opinion, that complication is being revealed by the analysis tools, not created, and all C code is actually that complicated and the programmers are merely kept in the dark by C's extensive structural deficiencies that make it so it's only safe to write in with these rather sophisticated tools, but the end result is still you're working in a much more complicated, demanding language with a much more baroque compilation process. Claims about C's productivity, compiler speed, probably execution speed, ease of programming, probably quite a few other things, all go flying out the window if this is the solution, and C looks eminently more replaceable.
- taeric 10y agoWe have not escaped the "wishful thinking" yet. Do I want there to be a replacement? Yes. I do my coding in other languages. Have I grown weary of the attacks on C? Also yes. Are not enough people using advanced toolchains? Yeah. I agree with that. But, this is effectively the same complaint that not enough people are using higher level languages. With the exception that fitting some of the extra tools on there is easier than switching languages.
- pjmlp 10y agoLint was created for C in 1979. In Dennis own words: "Although the first edition of K&R described most of the rules that brought C's type structure to its present form, many programs written in the older, more relaxed style persisted, and so did compilers that tolerated it. To encourage people to pay more attention to the official language rules, to detect legal but suspicious constructions, and to help find interface mismatches undetectable with simple mechanisms for separate compilation, Steve Johnson adapted his pcc compiler to produce lint [Johnson 79b], which scanned a set of files and remarked on dubious constructions." Taken from https://www.bell-labs.com/usr/dmr/www/chist.html https://www.bell-labs.com/usr/dmr/www/chist.html We are in 2016, and static analysis is still ignored by the majority of C programmers that "just get work done".
- taeric 10y agoApologies if this is rude, but I'm not sure what this is getting at. I know that static analysis is old. I also know that I have been guilty of ignoring it sometimes. Especially as I was learning. I think it is still in the wishful thinking world to think "better tools" should have won by now.
- pjmlp 10y agoThe thing is that the C working programming class doesn't value quality and secure code, performance FTW everything else gets done later, if there is time that is. Even the language authors were honest and: 1 - created a tool in 1979 that most C developers ignore even in 2016, 37 years later; 2 - realized that C was due its date and took part in Limbo and Go design Yet lots of C coders continue to improve this NIST list, every single day: https://nvd.nist.gov/visualizations/cwe-over-time https://nvd.nist.gov/visualizations/cwe-over-time For me wishful thinking, is the mentality that there are C developers out there that manage to write memory corruption free without using such tools. Never met any since my first contact with C in 1992.
- ArkyBeagle 10y ago
- kazinator 10y agoIndeed. When we look at Valgrind for instance, that only runs on Linux (and not all architectures). So you can only use it to debug C code that you can port to Linux (which requires it to be portable, which is different from "correct"), and you can only debug those issues in that code which you can reproduce in that Linux port.