Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>Your C code looks very unidiomatic to me, but I guess that is relatively a matter of taste (still I don't understand why would somebody use C if they don't like to write code in the 'classic' C style as seen in the original Unix and Plan 9 source).

Because we learned a lot about writing more robust and maintainable software since the 1970s. Also the original Unix source code was one thing more than anything: small. Really, really small. Mostly because it did not do much compared to a modern OS.

Things like encapsulation, separation of concerns, etc. only become important once the code grows to a certain size. Unfortunately some people think you need at least C++ for that, despite the fact that for example "private" member variables are way less private than incomplete C types. C is old, but that does not mean it is incompatible with modern software development approaches. Or that you have to write code as if your compiler only parsed the first few letters of an identifier. I think C's bad reputation in some circles can be explained by people only ever seeing 1970s style code.



Do you have any resources / books for writing modern C like this or is it all experiential from the trenches?


C Interfaces and Implementations: Techniques for Creating Reusable Software is the best thing I've seen on the topic, personally. http://www.amazon.com/Interfaces-Implementations-Techniques-...


I'd say "C programming: A modern approach" (K.N. King) should be a good candidate? Personally I like the book.


>Do you have any resources / books for writing modern C like this

No, sorry.

>is it all experiential from the trenches?

It's mostly about applying general principles of software construction like separation of concerns, encapsulation, robust interfaces, etc.


Maybe you could provide some of your favorite resources to those things, then?


This link gets posted on HN a lot but I've found it useful:

http://c.learncodethehardway.org/book/


I'm interested in this too.


>Because we learned a lot about writing more robust and maintainable software since the 1970s.

Plan 9 wasn't written in the 70s. OpenBSD is another example, probably a better example given that their sshd is far more important, and running on far more machines than anything you've ever written. So it seems rather disingenuous to suggest that the authors of such software are wrong for writing simple, concise, effective code instead of your bizarre vision of C.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: