
C interfaces and implementations
by David R. Hanson · first published 1996
114mentions
46recommended by
63HN commenters
2008–2026first – last mentioned
72% recommend23% neutral5% critical
Why HN recommends it
Shows how to design reusable C libraries with clean interfaces, ADTs, and exception handling built on setjmp. Suits programmers who know K&R and want to learn API design and code organization.
Common criticism: Literate, comment-heavy code style can distract from the prose
Summarised by Claude from recommending comments
Affiliate links. As an Amazon Associate I earn from qualifying purchases.








…exactly an up-to-date language resource at this point, and it doesn't really provide any guidance on the design and structure of systems in C (that's not it's purpose). You might have a look at Hanson's C Interfaces and Implementations: Techniques for Creating Reusable Software. That's focused on large projects and APIs, but it will give you a good sense of the "cognitive style" of C. 21st Century C is very opinionated, and it spends…
on “Ask HN: How do I learn C properly?” ↗…people who already know programming: Peter A. Darnell and Philip E. Margolis C - A Software Engineering Approach (3rd ed.) https://www.amazon.com/Software-Engineering-Approach-Peter-D... David Hanson C Interfaces and Implementations: Techniques for Creating Reusable Software (!st ed.) https://www.amazon.com/Interfaces-Implementations-Techniques... The first is clearly written and focuses on ANSI C (lexis, syntax and semantics),…
on “Ask HN: Best book to learn C in 2022?” ↗…don't think this argument stands. There are just as many great C books out there: * C Programming Language - by K&R * The Indispensable Guide to C with Engineering Applications - by Paul Davies * C Interfaces and Implementations - by David Hanson * A Retargetable C Compiler: Design and Implementation - by David Hanson * Graphics Programming Black Book - by Abrash with lots of Quake goodies
on “The myth of the Lisp genius” ↗For the past 10 years or so, I've been using an alternative to printf() that I lifted out of Hanson's _C Interfaces and Implementations_; in my tree, it's "fmt.c", and includes the family of fmt_<star> functions. They're just string processing code, and so are trivially portable to WinAPI, OS X, Linux, and FreeBSD. This is so…
on “ISO C is increasingly moronic” ↗C Interfaces and Implementations by Hanson. It'll give you back most of the things you depend on in Python, like variable length strings and dictionaries. I'm teaching a 4-month weekend C class for Ruby programmers starting in April,…
on “Ask HN: I use and love Python. What's the best book to learn C ?” ↗_C Interfaces and Implementations_ by David Hanson. I'm using it as the textbook for a weekend C class I'm about to run for a bunch of Ruby/Java programmers, because CII basically gives you back all the data structures you have in Ruby…
on “32 years on, K&R's "The C Programming Language" still stands alone” ↗I would recommend David R. Hanson's book C Interfaces and Implementations. It is an extremely well documented library and shows you how to design APIs properly. http://www.amazon.com/Interfaces-Implementations-Techniques-...
on “Ask HN: Examples of especially well-written C code?” ↗…header file and Make dependency problems, a few unix and processor portability problems and a few other stuff. The solution to those problems along with a fat library of useful routines are found in "C Interfaces and Implementations" by Hanson. It's a literate programming text where source code is interwoven with prose documentation and it's very self evident. Along with productive C programming you might need to look into the darker…
on “Ask HN: Learning C” ↗…books that expose how great hackers use that language and are targeted towards people really trying to master the language, eg: Common Lisp has PG's On Lisp and Peter Norvig's PAIP, C has David Hanson's "C Interfaces and Implementations", Forth has Leo Brodie's books and so on. Many other languages, even very popular ones, don't have these intermediate-to-expert level books written by outstanding hackers and are restricted to "Introduction…
on “Rich Hickey's Clojure Bookshelf” ↗…example, have Open Source code we can look at learn from. The best code I've seen: - Common Lisp - "Paradigms of Artificial Intelligence Programming" by Peter Norvig and "On Lisp" by Paul Graham C - "C Interfaces and Implementations" and "LCC- a compiler for ANSI C" both by David Hanson. I also found the code for the Player/Stage robotic sim framework surprisingly readable. I liked the Scala Actors library code as well. If any…
on “Ask HN: What source code is worth studying?” ↗My favorite C book is "C Interfaces and Implementations" (CII) by Hanson. It's an excellent bridge from Perl/Python to C; in particular, it gives you resizeable arrays and hash tables, which are the two things you will miss most from high level languages.…
on “Learning C and ASM, what's the way to go?” ↗…and Pitfalls_. Heck, the article (http://www.literateprogramming.com/ctraps.pdf) that grew into the book is even free online. Also, for anybody doing modern C work, I strongly recommend both Hanson's _C Interfaces and Implementations_ and Ierusalimschy's _Programming in Lua_, 2nd ed. The former nails writing good C libraries, and the latter covers one particular library that provides a portable, C-friendly, mature, efficient (http://luajit.org/),…
on “C Language Quirks” ↗…see, C is a really small language and "learning it in depth" includes learning arcane rules, such as what constitutes undefined behavior, what names are reserved, etc. I would recommend reading the "C Interfaces and Implementations" book by David Hanson. Another book that I'd recommend is "Expert C Programming (dark C secrets)" by van der Linden.
on “Ask HN: An Advanced C Tutorial” ↗While it's ostensibly about C, David Hanson's _C Interfaces and Implementations_ (http://sites.google.com/site/cinterfacesimplementations/) has a lot of good discussion about API design for libraries, how to handle errors gracefully, etc. Many points apply just as well to libraries…
on “Ask HN: Best books in API design” ↗C Interfaces and Implementations is really good: http://www.amazon.com/Interfaces-Implementations-Techniques-...
on “What do you want to see in Learn C The Hard Way?” ↗