by david_for_you · 5y ago · 0 comments
I would argue that this is why a "better C" can be useful, it's the kind of error that would be much harder to make in rust.
EDIT: Actually fopen would return NULL when file is not readable. My bad. Anyway, such problems are trivial to debug.
Understandably you didn’t put your whole effort into a small code example in a HN comment, but a language that allows one to do so without any errors would be big productivity and safety gain.
Wasn't it? It reminds me about the old article by Strostrup on c/c++ for beginners (I seem to link to this quite often, apologies if it gets repetitive):
https://www.drdobbs.com/learning-standard-c-as-a-new-languag...
One point of using c++ over c is that it should be easier to get a program that is in fact correct - regarding things like closing files etc. (that said conciously leaking some recources ("do and die") could be considered idiomatic c i suppose).