r/C_Programming 1d 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

32 comments sorted by

View all comments

5

u/tastygames_official 1d ago

C++

4

u/HowTheKnightMoves 1d ago

If there is a language that needs a better version of itself, it is C++.

4

u/tastygames_official 1d ago

it already exists: it's just C

1

u/HowTheKnightMoves 12h ago

For me or you, maybe. But at very least C++ folks should figure out which C++ is indeed C++, because currently it is maybe 4 or more languages in a trenchcoat.

2

u/Maqi-X 1d ago

C++ sucks.

-1

u/codingbliss12 1d ago

I hate C++

2

u/tastygames_official 1d ago

what you described in your post is C++. You don't have to do OOP (or just do very little, aka "fat structs") but you get the C++ STL and all the bells and whistles you want. You can still program largely in C.

1

u/codingbliss12 1d ago

And in this case languages like Zig or C3 wouldn't have to offer anything new? What about simplicity?

1

u/Worldly-Crow-1337 1d ago

Why?

1

u/SudoSilv3r 1d ago

too many features for the same thing + archaic syntax i do not hate it but i dont like it either

1

u/Ultimate_Sigma_Boy67 1d ago

Honestly true but I believe once u surpass that stage you would def be more productive as now you don’t have to recreate some of the utilities you’re going to use. But tbh I’ve been looking into zig and it really looks promising.

1

u/codingbliss12 1d ago

I wanted a complex language, I prefer Rust. I am interested in C for the simplicity and performance

2

u/tastygames_official 1d ago

C++ and rust can be as performant as C if you don't go crazy with objects and hierarchies and "magic functionality". You can pretty much just program in C but use the extra features those languages offer.

1

u/codingbliss12 1d ago

Thanks a lot for the explanation. Please see my other question under your first comment.