Skip to content
HomeVideosBooks
AllTopicsTrends
BlogsPodcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    Cover of C interfaces and implementations

    C interfaces and implementations

    David R. Hanson · 1996

    C Interfaces and Implementations describes how to use interface-based design in the C programming language, and it illustrates this approach by describing 24 interfaces and their implementations in detail. The source code in the book is interleaved with its explanation in an order that best suits understanding the code.

    Programming
    Open LibraryAmazon
    Stats for nerds
    46recommend
    114mentions
    63people
    2008–2026years
    77% recommend20% neutral3% critical

    Mentions per year

    2008201020122014201620182020202220242026

    What Hacker News says

    1. rramadassFeb 2026
      An article and previous discussion; Literate programming is much more than just commenting code - https://news.ycombinator.com/item?id=30760835

      Wikipedia has a very nice explanation - https://en.wikipedia.org/wiki/Literate_programming

      A good way to think about it is {Program} = {set of functional graphs} X {set of dataflow pipelines}. Think cartesian product of DAG/Fan-In/Fan-Out/DFDs/etc. Usually we write the code and explain the local pieces using comments. The intention in the system-as-a-whole is lost. LP reverses that by saying don't think code; think essay explaining all the interactions in the system-as-a-whole with code embedded in as necessary to implement the intention. That is why it uses terms like "tangle", "weave" etc. to drive home the point that the program is a "meshed network".

      To study actual examples of LP see the book C Interfaces and Implementations: Techniques for Creating Reusable Software by David Hanson - https://drh.github.io/cii/

      thread
    2. rramadassJan 2026
      > If at least C solutions took advantage of abstract data types as advocated by modular design approaches

      People have been writing C code with ADTs and "Modules" from the very beginning.

      Two excellent examples which come to mind are; Andrew Tanenbaum's Minix book Operating Systems Design and Implementation and David Hanson's C Interfaces and Implementations: Techniques for Creating Reusable Software.

      And of course the Linux Kernel is full of great modular C techniques which one can study.

      thread
    3. jll29Jul 2025
      The authoritative treatise of this topic is "C - Interfaces and Implementations" (known as CII) by David R. Hanson.

      His code is here: https://github.com/drh/cii

      thread
    4. jll29Mar 2025
      > The former is nicer to program while the latter is nicer to use.

      When I have such a situation, I'm inclined to write myself my own pre-processor (as I did for Pascal once in a previous millenium, on an Atari ST 520+), so that you can write in a style that is nicer to program in, which gets pre-compiled into something that is nicer to use from your client code.

      Nothing comes without downsides: the price of this is that other developers need to understand your idiosyncratic pre-processor, so this method works best for "single author" code/personal projects.

      What you don't want in a team is each coder having their own way of doing things, so that you cannot share libraries and helper functions.

      BTW, the best book on the OP's topic of production coding in C and implementing type-safe ADTs is Chris Hanson's book "C: Interfaces and Implementations." It contains some eye-opening tricks even for experienced developers in (standard) C.

      thread
    5. jll29Jan 2025
      This code is very beautifully written, thanks for sharing.

      However, you should consult the book "C: Interfaces and Implementations" by Dave Hanson, which has a library called "Arena" that is very similar to your "Pool"s, and it shows a few more tricks to make the code safer and easier to read (Chapters 5+6, 6 in particular).

      D. Hanson's book (written in the 'literary programming' style invented by Donal Knuth) also demonstrates having debugging and production implementations for the same C API to catch memory errors, and his book is from 1997:

        > Copyright © 1997 by David R. Hanson
      
      (He used to be a SE professor I Princeton before getting hired by Microsoft, I believe.)
      thread
    6. jll29Dec 2024
      Thanks for sharing. Simplicity is a good thing.

      In order to speed it up by reducing the number of malloc() calls, it may be worth adding a simple arena memory allocation measure: by allocating one larger block (e.g. 1 MB) initially and then doubling the memory size each time you run out, all malloc()/calloc() calls can become local salmagundi_alloc() calls that are just macro invocations that return an arena buffer pointer and also increment said pointer as a side effect.

      I also recommend you have a look at Chris Hanson's book "C: Interfaces and Implementations", which has a few neat C API tricks that your code could benefit from (e.g. for reducing name space pollution, for avoiding null pointer argument errors, API method naming etc.).

      thread

    Related

    Cover of The Standard C Library
    2009–2026

    The Standard C Library

    P. J. Plauger
    17 recommend · 29
    Cover of C Traps and Pitfalls
    2009–2025

    C Traps and Pitfalls

    Andrew Koenig
    19 recommend · 37
    Cover of Expert C programming!
    2008–2026

    Expert C programming!

    Peter Van der Linden
    88 recommend · 150
    Cover of A retargetable C compiler
    2010–2026

    A retargetable C compiler

    Christopher W. Fraser
    9 recommend · 23
    Cover of Modern Compiler Design
    2009–2016

    Modern Compiler Design

    David Galles
    1 recommend · 2
    Cover of The C Programming Language
    2007–2026

    The C Programming Language

    Brian W. Kernighan
    246 recommend · 604
    Cover of Understanding and Using C Pointers
    2013–2025

    Understanding and Using C Pointers

    Richard M Reese
    12 recommend · 22
    Cover of Compiler construction for digital computers
    2015–2026

    Compiler construction for digital computers

    David Gries
    1 recommend · 7