3 ms·
I said I would consider it a burden to write in pure C, not that I would not be able to do it. I would not need any documentation, but I would scratch my head f
by alexk7 16y ago
I said I would consider it a burden to write in pure C, not that I would not be able to do it. I would not need any documentation, but I would scratch my head figuring out how to organize a large program. I would need to write a lot of comments to replace things that do not exist in the language: const-correctness, memory management conventions, type-safe containers, etc.
- msbarnett 16y agoConst correctness has existed in C since 1999. Again, knowing C++, and even being able to constrain yourself to some C-like subset of it, is not the same as knowing C.
- nostrademons 16y ago"How to organize a large program" is a large part of what learning to program in a language means. BTW, const correctness is in C99, and memory management is usually done by writing constructors and destructors like C++ (except that they're real functions, often named stuff like <prefix>_init and _destroy or <prefix>_new and _free) and calling them manually. It's not as elegant as RAII, but if you write short functions with clear logic, you can usually ensure you cover all code paths. Remember that you don't have exceptions to screw up control flow in C. For type-safe containers, I just use void* containers with a comment indicating the intended type, but perhaps more experienced C programmers have a better system. Remember that Java didn't have type-safe containers until Java5, and honestly ClassCastException was a fairly rare error.