TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Books to learn advanced C programming

45 pointsby vshanabout 9 years ago
Hello,<p>I&#x27;ve recently been doing a lot of systems programming and low-level stuff. I&#x27;m hacking away on MIT&#x27;s xv6 kernel for my OS course. I want to improve my C skills, and want to learn the limits of what can be done with C, the preprocessor etc. I&#x27;d be really grateful if some one could direct me to resources that would help me out in this regard.<p>I want to basically learn how to write robust, readable and production-quality C which doesn&#x27;t crash to a segfault.<p>Also, is there a oft-used style guide for writing error-handling code in C?<p>Thank you.

10 comments

wrpabout 9 years ago
For good practices in writing high-reliability C, look at these:<p><a href="http:&#x2F;&#x2F;lars-lab.jpl.nasa.gov&#x2F;JPL_Coding_Standard_C.pdf" rel="nofollow">http:&#x2F;&#x2F;lars-lab.jpl.nasa.gov&#x2F;JPL_Coding_Standard_C.pdf</a><p><a href="http:&#x2F;&#x2F;www.leshatton.org&#x2F;MISRA_comp_1105.html" rel="nofollow">http:&#x2F;&#x2F;www.leshatton.org&#x2F;MISRA_comp_1105.html</a><p><a href="http:&#x2F;&#x2F;www.leshatton.org&#x2F;ISOC_subset1103.html" rel="nofollow">http:&#x2F;&#x2F;www.leshatton.org&#x2F;ISOC_subset1103.html</a><p><a href="http:&#x2F;&#x2F;www.embedded.com&#x2F;electronics-blogs&#x2F;embedded-systems-design-magazine-archive&#x2F;4216555&#x2F;Embedded-Systems-Design--May-2011" rel="nofollow">http:&#x2F;&#x2F;www.embedded.com&#x2F;electronics-blogs&#x2F;embedded-systems-d...</a><p>For the related topic of secure code, these books are good:<p>Mark Dowd. 2006. The Art of Software Security Assessment.<p>Robert Seacord. 2013. Secure Coding in C and C++, 2e.<p>For details on what is really going on inside C:<p>Paul Anderson. 1998. Advanced C: Tips and Techniques.<p>Kenneth Louden. 1997. Compiler Construction: Principles and Practice. Chapter 7.<p>For C gotchas and general good practices:<p><a href="http:&#x2F;&#x2F;www.cs.tufts.edu&#x2F;comp&#x2F;40&#x2F;reference&#x2F;CTrapsAndPitfalls.pdf" rel="nofollow">http:&#x2F;&#x2F;www.cs.tufts.edu&#x2F;comp&#x2F;40&#x2F;reference&#x2F;CTrapsAndPitfalls....</a><p>Allen Holub. 1995. Enough Rope to Shoot Yourself in the Foot.<p>P.J. Plauger. 1991. The Standard C Library. (It is partly a reference, but also has detailed discussion of the technical considerations faced in writing reliable code.)
评论 #11561946 未加载
tumbaabout 9 years ago
I suggest C Interfaces and Implementations: Techniques for Creating Reusable Software by David Hanson.[1] It focuses on helpful engineering practices for reliably and efficiently implementing algorithms in C.<p>I also second the recommendation for Peter van der Linden&#x27;s Expert C Programming for its masterful treatment of how C really functions, including the surprisingly frequent areas in which real-world constructs produce &quot;undefined behavior&quot; from the perspective of the C standard.<p>[1] <a href="http:&#x2F;&#x2F;www.amazon.com&#x2F;Interfaces-Implementations-Techniques-Creating-Reusable&#x2F;dp&#x2F;0201498413" rel="nofollow">http:&#x2F;&#x2F;www.amazon.com&#x2F;Interfaces-Implementations-Techniques-...</a>
lastofusabout 9 years ago
&quot;Deep C Secrets&quot; is quite good.<p><a href="http:&#x2F;&#x2F;www.amazon.com&#x2F;Expert-Programming-Peter-van-Linden&#x2F;dp&#x2F;0131774298" rel="nofollow">http:&#x2F;&#x2F;www.amazon.com&#x2F;Expert-Programming-Peter-van-Linden&#x2F;dp...</a>
kiloreuxabout 9 years ago
Of course there is the C programming language k&amp;r and also Expert C programming which kind of cool also, but if you want to make really great software and write great code, then your only is not books but real OSS, go write some small project, improve it, present it to community and have it criticized , and so on in a loop, look for big projects source and learn from them, one fairly interesting project is radare2[1], it&#x27;s a really cool project, please feel free to choose but look at projects already made and try to understand, you will learn a bunch from doing that.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;radare&#x2F;radare2" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;radare&#x2F;radare2</a>
ThatGeoGuyabout 9 years ago
Since it has yet to be mentioned yet, I&#x27;ll suggest Modern C by Jens Gustadt [1]. The book itself starts from basics and works up, but I found it to be much more reliable and filled with more practical advice than the common K&amp;R recommendation. Section &#x2F; Level 4 is not quite in it&#x27;s final form yet; however the book is mostly complete and gives a lot to think about. I suggest working through it, even if you skip the first few levels because of your base knowledge.<p>[1] <a href="http:&#x2F;&#x2F;icube-icps.unistra.fr&#x2F;img_auth.php&#x2F;d&#x2F;db&#x2F;ModernC.pdf" rel="nofollow">http:&#x2F;&#x2F;icube-icps.unistra.fr&#x2F;img_auth.php&#x2F;d&#x2F;db&#x2F;ModernC.pdf</a>
ahanjuraabout 9 years ago
Expert C Programming: Deep C Secrets bu Peter Van Der Linden is a classic and must see.(<i></i><i>Highly recommended</i><i></i>)<p>C Interfaces and Implementations: Techniques for Creating Reusable Software by David R Handon is another must check out.
ryanlmabout 9 years ago
Start writing every project, except web projects in C. You&#x27;ll be an expert in a few years. You&#x27;ll get really good at string handling. You&#x27;ll start to &quot;think in bytes&quot;.
blacksqrabout 9 years ago
_Write Portable Code_ by Brian Hook is excellent. Under the guise of teaching the writing of portable code, he teaches you to write good code, just as you describe.
arjnabout 9 years ago
The comp C faq is a good place once you have a little bit of C experience.<p><a href="http:&#x2F;&#x2F;c-faq.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;c-faq.com&#x2F;</a>
jti107about 9 years ago
this isnt a book...but i&#x27;ve heard the doom source code is quite good.
评论 #11561347 未加载