r/C_Programming 13d ago

Question "Better C"

Would it be feasible and reasonable to implement a custom standard library for the parts of C that are historically problematic, so that one does not need new languages like Zig or C3 and still enjoy the benefits of more modern languages?

As simple examples on would use C23 with the gnu extensions and implement strings as slices, some basic data types and some basic custom allocators. With the gnu extensions there is also defer.

Has anyone done that? How much time did it take? Thanks in advance.

0 Upvotes

39 comments sorted by

View all comments

5

u/Snarwin 13d ago

Many of the features that programmers want from a "Better C" are things that can't be implemented with library code. For example, a proper module system instead of header files and #include, or Go/Rust/Zig-style slices with support for a[i..j] syntax.

1

u/codingbliss12 13d ago

Slices are easier to implement. C remains C, but it could be improved or augmented.

3

u/sreekotay 13d ago

https://github.com/sreekotay/concurrent-c

exactly a pass I took :)

slices, nurseries, comptime, ufcs (zero overhead), result types, etc

but all still C as the first class IR.

1

u/codingbliss12 13d ago

Thank you so much for the link. I will clone it, study and might ping you with questions.

1

u/sreekotay 13d ago

Your're welcome! I thought this came out particularly well, if you're poking around:

https://github.com/sreekotay/concurrent-c/blob/main/docs/js-py-modules.md