3 ms·
Create a language with semantics exactly like C, but the standard library completely replaced. Call it in a way that avoids trademark disputes (e.g. CWSL, C Wit
by nine_k 2y ago
Create a language with semantics exactly like C, but the standard library completely replaced. Call it in a way that avoids trademark disputes (e.g. CWSL, C With Sane Library). Get GCC and LLVM support it, which should be reasonably easy, because both support compiling code that does not rely on libc (though OS entry point code, etc should be wired in).
Would it be easy enough to port important C code to it, given that most of the libc-supplied functions, and functions transitively depending on these, would have to be rewritten? Would it be worthwhile, compared to rewriting such code it in Zig, Rust, or Ada?
- pjmlp 2y agoThere have been multiple attempts at this, how many folks heard of Safe-C, C3,... ? Only bothering to list two examples, there are many others, even Cyclone is partially C compatible, guess what came out of Cyclone.
- oguz-ismail 2y ago>Safe-C import statements are a deal breaker >C3 shit syntax >Cyclone vaporware
- MyOutfitIsVague 2y agoWhy in the world would import statements be a deal breaker?
- oguz-ismail 2y ago> The .h and .c files of a component must always be stored in the same folder so that the compiler can find them
- pjmlp 2y agoLearn to use your compiler switches.
- shakna 2y agoD began life as a re-engineered C++. (I'm sure Walter will correct me if I say any more). There's a Safe C++ extension proposed for Clang [0]. But those are C++, not C. A little different kettle of fish. Gnome's Vala [1] aims to be the "smoothest C off-ramp". It does compile to C, but with GObject taking control of everything. There's CheckedC [2], which adds optional bounds checking to C, and was backed by Microsoft until recently. There's the Linux kernel's nolibc [3], which I've enjoyed the heck out of using, but it is rather constrained. There's C's own Annex K [4], that almost nobody has implemented, and every compiler developer hates and can poke holes in. GCC and LLVM have both repeatedly said they won't support it. (So much as easy to get them to support things...) GCC already has a number of memory safe languages, though. Most of which, because they're part of the same compiler suite, can interact with other languages that GCC has. Like the D or Go frontends. [0] https://discourse.llvm.org/t/rfc-a-clangir-based-safe-c/83245 https://discourse.llvm.org/t/rfc-a-clangir-based-safe-c/8324... [1] https://vala.dev/ https://vala.dev/ [2] https://www.checkedc.org/ https://www.checkedc.org/ [3] https://lwn.net/Articles/920158/ https://lwn.net/Articles/920158/ [4] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1106.txt https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1106.txt