3 ms·
C is a very pragmatic language for writing software on a PDP-11 fifty years ago. You aren't doing that, so every single place where C made compromises to facili
by tialaramex 3y ago
C is a very pragmatic language for writing software on a PDP-11 fifty years ago. You aren't doing that, so every single place where C made compromises to facilitate that you're paying a price for something you don't need or even want.
For example you want fat pointers, particularly for slice types. On a PDP-11 spending two registers for these types is extravagant, today this seems ridiculous, but C still doesn't provide any fat pointer types. So either you have to roll your own (and with them libraries of code to use them) or put up with whatever was a good idea in the 1970s. The most famous slice type is Rust's &str or C++ std::string_view, a fat pointer for referring to text - strings in other words, but not the mutable, owned, auto-growing strings you might associate with higher level languages, this is just the simple concept of some text. C can't do that, what C gives you is a pointer to a byte, pointer arithmetic and a stern admonition to stop when you reach a byte with a zero value... or you can roll your own slice types.