Re:Modern C++ for C Programmers (2018)
by habibur on Saturday July 24, 2021 @02:43AM
(#27938958)
Because the underlying OS API expects a char* as file name.
[ Parent
| on HN ]
Rather, the underlying OS requires an array of bytes terminated by 0 which can be hidden behind a decent API. The type being poor at expressing this is not a limitation of the OS but of the C type system. E.g in zig this would be `[*:0]u8` which is "a pointer to a region of memory of unknown length terminated by a 0 sentinel value". It's still a pointer but nothing says the type system can't track more state around it.
So why isn't the Linux API properly encapsulated for C++?
Rust does that.
C++ got off on a weird I/O direction. That
file << item << item;
syntax never really caught on. Someone liked Currying too much.