sp.h is the standard library that C deserves

16 points by winter


FRIGN

I would advocate for more readability, especially for a new library. Why all the abbreviations? What is sp_da()? etc.

riki

Author seems pretty high on LLMs and this text reads a bit like it was chewed on by an LLM.

This gives me serious doubt as to whether I should trust that the implementation is written by a real person, too.

lemon

I think "Goals" including "Be extremely portable" conflicts with Non-Goals of "Obscure architectures and OSes". The author's idea of obscure is anything that isn't Windows/MacOS/Linux on x86_64/aarch64, which is telling.

In other words, allocators. They do so by forcing programs to accept that “the ability to allocate any amount of memory from the ether” is not a primitive; it is a fiction. The operating system hands out pages. The runtime on top of it, most often called via malloc(), is what implements the often useful fiction that non-page-sized amounts of memory can be allocated.

But in my experience, that is an unfortunate default rather than something that is true, and this library seeks to make it opt-in rather than opt-out.

Typically, we call these abstraction layers and not "fictions", and most people would agree that allocators are better idea than calling mmap for every allocation, fresh or resizing.

Surely a malloc() style allocator is a better default than that. (Granted, there's also an arena allocator, but even his examples don't seem to use it)

The math library also contains some gems:

f32 sp_sys_sinf(f32 x) {
  while (x > 3.14159265f) x -= 6.28318530f;
  while (x < -3.14159265f) x += 6.28318530f;
  f32 x2 = x * x;
  return x * (1.0f - x2/6.0f * (1.0f - x2/20.0f * (1.0f - x2/42.0f)));
}

This will not even terminate for some inputs.

Overall, highly non-serious, for something that calls itself a "high quality, ultra portable standard library" and claims "there is nothing like it.". I would be more charitable if it weren't for the lofty claims and the obvious heavy LLM involvement.

ayba

Ignoring the LLM controversy, this project seem to surf the wave of "modernity" without bringing much more thought with it. Nonetheless always nice to see another approach to the design of a general-purpose C library.

xnacly

I dont think c's issues can be solved with just building a new standard library, ofc libc has its issues, but c has enough issues without it. Maybe filc can solve most issues i have, but i dont think ill ever again choose c for a new project. And i love the minimalism compared to c++ or rust.