HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
ludocode
pottery
C2020–2022
ludocode / pottery

pottery

Pottery - A container and algorithm template library in C

2Distinct people
13Mentions
1Explicit recommenders
133GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Pottery - A container and algorithm template library in C

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

I wrote a toy chess engine a few weeks ago as well as an example for one of my open source libraries [1]. I was inspired by a video of someone writing one in half an hour [2],…

ludocode used a recommendation phrase. One indexed comment matches. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

  • glouw/ctl · linked in 2 of the same discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by month13 dated mentions

Observed mentions: 2020-12-16 15:39:12 UTC to 2022-05-17 05:06:42 UTC.

012342020-12-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 4 mentions; 1 submissions, 3 commentsDec 20202021-01-01 00:00:00 UTC to 2021-02-01 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments2021-02-01 00:00:00 UTC to 2021-03-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-03-01 00:00:00 UTC to 2021-04-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2021-04-01 00:00:00 UTC to 2021-05-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2021-05-01 00:00:00 UTC to 2021-06-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2021-06-01 00:00:00 UTC to 2021-07-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-07-01 00:00:00 UTC to 2021-08-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2021-08-01 00:00:00 UTC to 2021-09-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 commentsAug 20212021-09-01 00:00:00 UTC to 2021-10-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-10-01 00:00:00 UTC to 2021-11-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-11-01 00:00:00 UTC to 2021-12-01 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments2021-12-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-01-01 00:00:00 UTC to 2022-02-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-02-01 00:00:00 UTC to 2022-03-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-03-01 00:00:00 UTC to 2022-04-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-04-01 00:00:00 UTC to 2022-05-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-05-01 00:00:00 UTC to 2022-06-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsMay 2022

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
Dec 20202020-12-01 00:00:00 UTC2021-01-01 00:00:00 UTC413
Jan 20212021-01-01 00:00:00 UTC2021-02-01 00:00:00 UTC211
Feb 20212021-02-01 00:00:00 UTC2021-03-01 00:00:00 UTC000
Mar 20212021-03-01 00:00:00 UTC2021-04-01 00:00:00 UTC101
Apr 20212021-04-01 00:00:00 UTC2021-05-01 00:00:00 UTC101
May 20212021-05-01 00:00:00 UTC2021-06-01 00:00:00 UTC101
Jun 20212021-06-01 00:00:00 UTC2021-07-01 00:00:00 UTC000
Jul 20212021-07-01 00:00:00 UTC2021-08-01 00:00:00 UTC101
Aug 20212021-08-01 00:00:00 UTC2021-09-01 00:00:00 UTC000
Sep 20212021-09-01 00:00:00 UTC2021-10-01 00:00:00 UTC000
Oct 20212021-10-01 00:00:00 UTC2021-11-01 00:00:00 UTC000
Nov 20212021-11-01 00:00:00 UTC2021-12-01 00:00:00 UTC211
Dec 20212021-12-01 00:00:00 UTC2022-01-01 00:00:00 UTC000
Jan 20222022-01-01 00:00:00 UTC2022-02-01 00:00:00 UTC000
Feb 20222022-02-01 00:00:00 UTC2022-03-01 00:00:00 UTC000
Mar 20222022-03-01 00:00:00 UTC2022-04-01 00:00:00 UTC000
Apr 20222022-04-01 00:00:00 UTC2022-05-01 00:00:00 UTC000
May 20222022-05-01 00:00:00 UTC2022-06-01 00:00:00 UTC101

What Hacker News says

13 sources
I think it's common for C programmers to roll their own. I did the same [0]. I went pretty deep into composable C templates to build mine so it's more powerful than most. The containers can handle non-bitwise-movable types with full C++-style lifecycle functions and such, and the sort algorithms can handle dynamic and non-contiguous arrays (they are powerful enough to implement qsort() [1], which is more than I can say for any other C sort templates I've seen.) My reasoning for the complexity at the time was that any powerful container library is going to be reasonably complex in implementation (as anyone who's looked at STL source code knows), so it just needs to be encapsulated behind a good interface. I'm not so sure that's true anymore. These sorts of simpler libraries like the one linked here definitely seem to be more popular among
Read the rest
C programmers. I think if people are using C, it's not just the C++ language complexity they want to get away from, but also the implementation complexity of libraries and such. There's a balance to be had for sure, and I think the balance varies from person to person, which is why no library has emerged as the de facto standard for containers in C. [0]: https://github.com/ludocode/pottery [1]: https://github.com/ludocode/pottery/tree/develop/util/potter...
In Common libraries and data structures for C
I recently released a new version of my C MessagePack library MPack [1] with a cool new feature to dynamically calculate the size of maps and arrays during encoding. Having to always specify the size of containers up-front was a pain. I believe it's the only C/C++ MessagePack implementation that can do this. Of course bugs appeared immediately so I am working on a patch release. I am also working on and off on my C template library Pottery [2]. I haven't pushed any code in a while; having a day job and young children makes progress slow :( [1]: https://github.com/ludocode/mpack [2]: https://github.com/ludocode/pottery
In Ask HN: What you up to? (Who doesn't want to be hired?)
But then your code can't be used by anyone without your preprocessor. There is a lot of value in plain C metaprogramming because it can be compiled with an ordinary C compiler. You can, however, use a script to generate some of the preprocessor boilerplate while still having the templates configurable and instantiable with an ordinary C compiler. This is how my metaprogramming library Pottery works: https://github.com/ludocode/pottery It uses #include for templates rather than code block macros, something the article doesn't really go into. It's more powerful this way and the templates are far more readable; aside from the generated metaprogramming boilerplate, the templated code looks like (and preprocesses to) ordinary C.
In Metaprogramming custom control structures in C (2012)
I built Pottery, a C template library. It provides vectors, hash tables, binary search trees, priority queues, sort algorithms, etc. https://github.com/ludocode/pottery These templates are composable: high-level templates are implemented using lower-level ones. It also supports custom lifecycle functions, so you can tell containers how to copy, move, destroy your values; it supports custom array access functions, so you can use algorithms like sort or heap over a generalized array that may not be contiguous in memory; and more. There is still nothing else like it as far as I know. The closest alternative is CTL but it doesn't have any of those features: https://github.com/glouw/ctl/
In Ask HN: What are some tools / libraries you built yourself?
Yes! The include style of templates in C is way better than the old way of huge macros to instantiate code. The template code can look mostly like idiomatic C, it interacts way better with a debugger, it gives better compiler errors... everything about it is better and it's finally starting to become more popular. I've open sourced my own C template library here: https://github.com/ludocode/pottery Not only does it use the #include style of templates, but it actually makes the templates composable. It takes this idea pretty far, for example having a lifecycle template that lets you define operations on your type like move, copy, destroy, etc. This way the containers can fully manage the lifecycles of your types even if they're not bitwise movable. There's also this other more popular C template library, one that tries to more directly por
Read the rest
t C++ templates to C but with a lot less features: https://github.com/glouw/ctl/
In Type-safe generic data structures in C
This article doesn't really make it clear but the merge sort discussion is specifically about glibc's implementation of qsort(). glibc's qsort() and Wine's qsort() are the only ones I know of that use merge sort to implement qsort(). Most implementations use quick sort. I recently did my own benchmarking on various qsort()s since I was trying to implement a faster one. The various BSDs and macOS qsort() are all faster than glibc at sorting integers and they don't allocate memory: https://github.com/ludocode/pottery/tree/master/examples/pot... Of course sorting is much faster if you can inline the comparator so a templated sort algorithm is always going to be faster than a function that takes a function pointer. But this does not require C++; it can be done in plain C. The templated intro_sort from Pottery (linked above) is competitive wit
Read the rest
h std::sort, as are the excellent swensort/sort templates: https://github.com/swenson/sort
In Beating Up on Qsort (2019)
This is true, but your second point is difficult to do in C. You would have to have a set template and a separate lookup template to search the set based on a key type. This is actually how heterogeneous lookup is implemented in C++: it's a template within a template. This is not a big deal in C++ because templates are instantiated automatically but we're instantiating templates manually in C. It's also only available as of C++14 and only on ordered containers, not hash tables. It's more straightforward to combine these templates: make map the fundamental type, but make values contain their keys and make the key type default to the value type if omitted. This way it's both a map and a set. My own C hash table template does it this way [1]: it stores only a value type and not keys, but there is an optional separate key type used for lookup
Read the rest
s, hashes and comparisons. To make it a map, you provide both a key comparison expression and an expression to convert values to keys. [1]: https://github.com/ludocode/pottery/tree/master/include/pott...
In C Template Library
ludocode·Dec 24, 2020Recommendation phrase
I wrote a toy chess engine a few weeks ago as well as an example for one of my open source libraries [1]. I was inspired by a video of someone writing one in half an hour [2], so I also assumed it would take a day or two at most. It took more like a week. But it was very satisfying to not be able to beat my engine anymore. I highly recommend that all programmers with even a passing interest in chess spend some time writing an engine. [1] https://github.com/ludocode/pottery/tree/master/examples/pot... [2] https://youtube.com/watch?v=nzObJ2BpKrk
In Building My Own Chess Engine

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.