Re:C Questions and Answers
by _RPM on Wednesday March 04, 2015 @12:08AM
(#9142787)
This reminds me of tests I took in earlier CS classes. Knowing those things are utterly useless in practice.
[ Parent
| on HN ]
Re:C Questions and Answers
by gamegoblin on Wednesday March 04, 2015 @01:57AM
(#9143052)
My CS101 prof would give 50-100 line blocks of code, and hidden in them somewhere would be something like:
if(condition); {
some stuff
}
Note the semicolon after the if-statement.The tests became games of "find the semicolon or = in place of ==". Ugh.
Re:C Questions and Answers
by oneeyedpigeon on Wednesday March 04, 2015 @03:13AM
(#9143214)
Thankfully, your compiler probably warns about this nowadays, making such pointlessness obsolete.
And the static analysis tool you're hopefully using.
A lot of these are cases where I've seen actual bugs. Popular ones are >= 0 checks, dumb assumptions about overflows and null derefs, and the always popular "use an int when it should be size_t".
What is your main programming language; in which you do most of the work?
C, actually, at the moment. But I don't use C for work or web development.
I hope this thread gave you some idea how important these thing really are.
Re:C Questions and Answers
by frozenport on Wednesday March 04, 2015 @01:43AM
(#9143013)
Compilers are increasingly optimizing out UB, recently fixed a problem where `std::unique_lock` was optimized as it was referenced from an `std::thread` defined at the top of the class. The future is now!
only useless if you never make a mistake ever. This shows what you should be vigilant for (alternatively , an argument for using a language with more checks)
As someone on HN once said (in jest), it's easy to write bug-free C, you just need to never make a mistake ever and spend a million hours auditing it.
Re:C Questions and Answers
by icebraining on Wednesday March 04, 2015 @04:40AM
(#9143413)
If those mistakes are so teachable, wouldn't it be better to put them into a linter?