Earlier quoted context omitted.
Author here. It is not currently in production, but it is part of a project in Azure which will go to production at some point. I'm actually leaving Microsoft next week and fully intend to keep working on it if I can reach an agreement to do so with my new employer.
If an agreement can't be reached with your new employer are you certain that folks at Microsoft will continue maintaining this library? I'd like to experiment with it but have trepidation regarding future development.
Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
81–90 of 103 posts
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#82Earlier quoted context omitted.
Switching to C++ is relatively easy in an existing codebase. It's in many cases as simple as renaming a file from .c to .cpp. But for writing something from scratch it's better to use Rust.
Renaming c. to .cpp may work with ancient c89 code, but not with anything remotely modern. But while the code then is technically C++, it is not better. I still prefer C for new projects to any other language, because I value short compilation time and reduced complexity. For me, this translates in higher productivity and more fun. With modern tooling, also most C issues are detected early.
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#83It'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
#84Earlier quoted context omitted.
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…
Good thing there are safe languages that compile to C, such as Nim.
I personally struggle with often being stuck on c99, not even c11.
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#85Earlier quoted context omitted.
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'll have to give the access attributes a look, I hadn't heard of them. (My team were sitting back on gcc-12, so not up to speed on the latest.) 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?
I use c23 features but also vm-types for bounds checking which are older (i need the statement expression extension though): https://godbolt.org/z/T96T89Yhc
yes, with us I mean wg14 (or just me).
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#86Earlier quoted context omitted.
Renaming c. to .cpp may work with ancient c89 code, but not with anything remotely modern. But while the code then is technically C++, it is not better. I still prefer C for new projects to any other language, because I value short compilation time and reduced complexity. For me, this translates in higher productivity and more fun. With modern tooling, also most C issues are detected early.
Slightly tweaking C code to allow it working in C++ is still much easier compared to full rewrite in some other language.
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#87Author 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…
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#88Earlier 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. What do you think C would need in order to reach the user experience of those languages?
Because it is C not Zig/Odin. The mental/ecosystem cost to use a new language is way way under-estimated in most cases.
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#89there are no good reasons we don't do this in the standards themselves, C, C++, and POSIX should all be working on editions that add safer APIs and mark unsafe APIs as deprecated, to start a long term migration. we know how to do this, we've had a lot of success with this. there are real engineering concerns, sure, but they're not reasons to not do it. compilers and library chains can retain support for less safe var…
The reason this wasn't done by the standards committees is that they spent decades refusing to admit there was even a problem they could help fix. And if there was a problem, it was easily avoided by just writing better code. And if writing better code wasn't enough, well it was certainly too expensive to provide as a debug option. And if it wasn't too expensive to provide as a debug option, the implementors should r…
Still looking forward to the day C supports something like std::string, std::string_view, std::span, std:;array.
Which starting with C++26 finally have a standards compliant story about having bounds checks enabled by default.
Re: Lib0xc: A set of C standard library-adjacent APIs for safer systems programming
#90This 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 think most people who are into c that I’ve met quite like header only libraries. Copy paste as a package manager does have its benefits.