Earlier quoted context omitted.
This is a misrepresentation based on a misunderstanding on how standardization works. The C standard committee has long recognized the need for better safety and carefully made it possible so that C could be implemented safely. But the process is that vendors implement something and then come together during standardization so that it is compatible, not that the standardization is the government that prescribes top-d…
Stop mixing C and C++, tons of people on Unix still hate C++ (Motif a bit less) for being un-Unixy and megacomplex, even more today. Die had Unix and C people created Plan9 and now Go, which is maybe the other succesor to C before Inferno and Limbo, where programming it's more simpler than the whole C and POSIX clusterfux (even Plan9 and 9front itself can be called a "Unix 2.0"). C++ is something else. Heck, it's oft…
Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
71–80 of 103 posts
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#72This is great. Other things needed for a great C development environment are a standardized build process plus build tools and a standardized packaging system.
I do NOT want a package manager in my c code. I'm perfectly content with cloning a git repo from my cmake script.
And there is plenty to choose from if you don't like one or another build system.
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#73The title looks very promising. I’ve added this library to my to-do list to take a deeper look at it. Using this standart library within restricted safe subset of C++ can be a strong opponent for Zig (at least for myself).
As the readme describes it as basically established industry patterns passed down through word of mouth.
I find It's difficult to find deeper level C programming techniques like these normally.
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#74It's just an excuse not to use safe languages. And adopting it isn't that easy - one need to learn how the new library works or even rewrite old working and tested code with it.
C remains widespread for unique reasons that not many other languages actually quite grasp.
Using C for a destop application should probably stop being done in light of many more languages more suited for the domain.
But there is no replacement for C in hard embedded systems. And there is no replacement for C in the massive domain of legacy c systems.
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#75Author here, I posted this in Show HN but someone clearly beat me to it. So I'll repost my blurb from there. Various patterns for safer C programming have been cargo-culting around the industry for decades. Because the language evolves intentionally slowly, these patterns rarely get folded into the language as first-class constructs and are passed down through the generations in a sort of oral tradition of programmin…
Thanks! Two notes: GCC has its "access" attributes which can give you similar bounds safety as clang. Please see also my experimental library. https://codeberg.org/uecker/noplate/ While I do not had enough time to polish it yet, I think it provides some very nice interfaces with improve type and bounds safety, and are also rather convenient. Also I wonder what parts are redundant if you have FORTIFY_SOURCE ? (And tha…
I think I had seen noplate before -- looks like you're taking advantage of the anonymous struct compatibility changes in C23? Those are going to open up a lot of possibilities. Regardless I'd love to stay in touch -- by "us" do you mean the working group?
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#76Earlier quoted context omitted.
This is a misrepresentation based on a misunderstanding on how standardization works. The C standard committee has long recognized the need for better safety and carefully made it possible so that C could be implemented safely. But the process is that vendors implement something and then come together during standardization so that it is compatible, not that the standardization is the government that prescribes top-d…
Stop mixing C and C++, tons of people on Unix still hate C++ (Motif a bit less) for being un-Unixy and megacomplex, even more today. Die had Unix and C people created Plan9 and now Go, which is maybe the other succesor to C before Inferno and Limbo, where programming it's more simpler than the whole C and POSIX clusterfux (even Plan9 and 9front itself can be called a "Unix 2.0"). C++ is something else. Heck, it's oft…
https://www.tuhs.org/Archive/Documentation/TechReports/USG_L...
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#77Earlier quoted context omitted.
I think defer has been included in the next round of working group proposals for C2y, but I don't think Apple's clang has it. Maybe it's there as a language extension and I just didn't see it. What lib0xc has is some cleanup attributes that you can apply to variables to e.g. automatically free a heap allocation or close a file descriptor, at end of scope. Personally, I like variable annotations much more than defer f…
> I've also found that using those attributes inherently pushes your code to make ownership more explicit. I personally stopped being terrified of double-pointers and started using them for ownership transfers, which eliminates a large class of bugs. This is very interesting. Do you have a practical example?
void *__free p = NULL;
func(&p); // func zeroes p to claim ownership
// end of scope, p is NULL, nothing happens // if func was not called, p is freed
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#78Look, C is so simple, you can implement a compiler in under 10K lines of code on a new platform. And then spend the your life dodging bugs and come up with a zoo of bizarre macros to keep you safe.
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#79It's just an excuse not to use safe languages. And adopting it isn't that easy - one need to learn how the new library works or even rewrite old working and tested code with it.
If i cannot use GCC i cannot compile to half the embedded platforms i work with on a daily basis. C remains widespread for unique reasons that not many other languages actually quite grasp. Using C for a destop application should probably stop being done in light of many more languages more suited for the domain. But there is no replacement for C in hard embedded systems. And there is no replacement for C in the mass…
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#80Earlier quoted context omitted.
> This might be a dumb question, but using this + clang bounds-safety, whats the difference between this and something like Zig or Odin. I really need to learn more about Zig, but from what I know, there are still worlds of possibilities that a modern, well-designed language offers over something like lib0xc. Zig's ability to evaluate any expression at compile-time is one such example. But generally, lib0xc gives you…
Why not pick a different language if you want different features? Why does C specifically need to change, if there are already Zig, Rust etc.? Why Must C be safe, rather than people writing safer code in it or transfering to other languages if they cannot be bothered?
I don't think that the choices should be "self-driving cars" and "cars with no seatbelts, airbags, or crumple zones" with nothing in between.