Hacker News new | ask | show | jobs
by iamyemeth 1083 days ago
I'm always a fan of 80% solutions implemented in C. I think the library is pretty nice, and as someone who's experimented with trying to add quality of life features to C99 with macros I think the implementation is actually pretty clean and readable as far as these kind of implementations go.

That being said, I think the ergonomics of the approach taken by Sean Barrett in stb_ds is much nicer than the #define ALG_TYPE, #define ALG_PREFIX approach, although I'm sure it wouldn't be a big stretch to make something similar that was compatible with it.

My feeling is that you could get pretty far with something like Sean Barrett's stb_ds + Salvatore Sanfilippo's sds and then a generic algorithm library like this one

1 comments

I think the difference is that stb_ds is a datastructures library and this is for algorithms. This algorithm library will also look like a completely regular C library if you just use separate .h and .c files to instantiate declarations and the implementation, I think it's very clean.
I meant more from the perspective that stb_ds achieves type safe generics in C using macros but without using defines.

It would be interesting to see if something similar could be achieved for an algorithm library.

It would be interesting but I prefer the approach in this post - because the templating macros are isolated out into a "module" and it does not great spread across the user code.