3 ms·
As a C++ programmer who delved deeply into nginx, I think that your chosen example of "high quality C code" is telling of the state of C programs. It could be o
by unscaled 11y ago
As a C++ programmer who delved deeply into nginx, I think that your chosen example of "high quality C code" is telling of the state of C programs. It could be one of the best specimens of C code in terms of organization, but absolutely speaking it's one of the best large code-bases I had to deal with:
1. Almost devoid of any documentation.
2. No ADTs - all struct fields are directly accessed, even though there are sometimes very complicated invariants that must be preserved (and these invariants are not documented anywhere, of course).
3. Ultra-short variable names that really describe nothing but their types (it's like Hungarian notation with only the notation part).
4. These mystery variables are all defined in the top of the function of course, making them hard to trace. Does anyone even compile Nginx with C89?
5. Configuration parsing creates a lengthy boilerplate that's really hard to track.
6. Asynchronous code is very hard to track, with a myriad of phase-specific meaning for return codes, callbacks and other stuff that makes reading Boost.ASIO code look like a walk in the park.
I think it really shows the sad state of C programming. Die-hard C programmers always complain C++ is hard to read because of its template and OOP abstractions, and it sometimes really is a mess to read, but C is even harder since large programs always re-implement their own half-assed version of OOP and template-macros inside.
- danmaz74 11y ago> but absolutely speaking it's one of the best large code-bases I had to deal with You meant "one of the worst"?
- paulddraper 11y agoEither that, or best example of the worst