https://spader.zone/sp/#null-terminated-strings-are-the-devi... Pointer/length is not just for strings - but for all arrays. See my proposal: https://www.digitalmars.com/articles/C-biggest-mistake.html
I suggest using a slightly different array operator syntax for fat pointer arrays: "char a[|..|]" instead of just "char a[..]" to make them visually distinct and indicate that element access has additional bounds check. (syntax inspired by ocaml)
sp.h: Fixing C by giving it a high quality, ultra portable standard library
151–160 of 222 posts
Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library
#152https://spader.zone/sp/#null-terminated-strings-are-the-devi... Pointer/length is not just for strings - but for all arrays. See my proposal: https://www.digitalmars.com/articles/C-biggest-mistake.html
Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library
#153> Principles > Be extremely portable > sp.h is written in C99, and it compiles against any compiler and libc imaginable. It works on Linux, on Windows, on macOS. It works under a WASM host. It works in the browser. It works with MSVC, and MinGW, it works with or without libc, or with weird ones like Cosmopolitan. It works with the big compilers and it works with TCC. > And, best of all, it does all all of that becaus…
Exactly. This shows that "extremely portable" is actually marketing for "It supports a number of platforms. In my opinion, this number is big".
Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library
#154> C is valuable because it’s simple This is funny to me because just today some friends gave me a link to a C quiz: https://stefansf.de/c-quiz/ From which I gathered that it is a much more cursed language than I remembered. Maybe we all just got used to C and just happen to use a minimal subset. The problems with C are not mainly with the standard library, but any effort to improve things should be lauded.
Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library
#155> C is valuable because it’s simple This is funny to me because just today some friends gave me a link to a C quiz: https://stefansf.de/c-quiz/ From which I gathered that it is a much more cursed language than I remembered. Maybe we all just got used to C and just happen to use a minimal subset. The problems with C are not mainly with the standard library, but any effort to improve things should be lauded.
Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library
#156Earlier quoted context omitted.
Yes, unfortunately the threading primitives require libc. Ditto subprocesses. It's on my list. But regarding: "Oops... apparently this is vibecoded. Welp, I just wasted ten minutes of my life reviewing slop that I'm not going to get back." Do not talk to people like this. I don't care if you don't like the library, or if you found a flaw in it. I am a regular person who wrote this code for no other reason than I thou…
You're absolutely right. I should have expressed my late-night frustration more kindly.
Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library
#157Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library
#158Earlier quoted context omitted.
“Portable”, in the context of how it was used, generally refers to software using platform agnostic idioms. If you have to write extensive patches to actually port the software, then it’s only “portable” in the same sense that any software can be ported with enough effort. Ie “Foo is portable. You just have to write a write a whole new kernel to port it”
Is the Foo kernel 75% of the code base, 5% or 0.01%?
> “Portable”, in the context of how it was used, generally refers to software using platform agnostic idioms.
Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library
#159I do not want to include and compile a standard library for every file that includes it. Why do standard library headers always have to be insane?
Have you considered compiling it into a binary of your choice? It works perfectly well as a traditional library. The only cost you pay is re-parsing the header part once per TU. Because C is so simple, this is virtually free. In any case, calling it insane makes me feel disrespected and I would prefer if you didn't do that.
You are not just parsing it. The header includes the implementation too which will get compiled. Then the linker has to do extra work in order to deduplicate all of this extra code that was made.
>Because C is so simple, this is virtually free.
This is not virtually free needing to compile a standard library for every file in one's project.
>In any case, calling it insane makes me feel disrespected
I would recommend you not take it personally. Fortunately, for better or worse software ends up being pretty robust so it can tolerate a lot. Even if you have to recompile the same standard library hundreds of times, it will eventually compile.
Re: sp.h: Fixing C by giving it a high quality, ultra portable standard library
#160Earlier quoted context omitted.
It's an odd stance for a C library. In my experience, odd platforms are the main place that C is used in 2026. If you're writing a new Windows or Linux or MacOS or WASM program, it's not likely to be in C. But lots of new microcontroller software is still being written in C. And he's already hit the hard targets. Many obscure OS's are generally UNIX like and should be easy ports. Many obscure arch's usually are runni…
I have no philosophical complaints with supporting odd architectures in general. I agree that most obscure targets are probably not that much code, since the library is factored with this in mind (e.g. basic WASM support took an afternoon). It's stated as a non-goal simply because it's not the most valuable thing I can do with my time. My fundamental stance is that writing new Windows or Linux or macOS or WASM progra…