4 ms·
The C char type is an aberration. (and always has been) The simple fact that a char can be defined as unsigned is telling enough. C should have defined a byt
by stephc_int13 4y ago
The C char type is an aberration. (and always has been)
The simple fact that a char can be defined as unsigned is telling enough.
C should have defined a byte type long ago.
Overall, I think the whole C standard library aged poorly, the semantics, the somewhat cryptic and overly abbreviated naming style, all the corner cases with old types like char that was used instead of the missing byte type.
I very rarely use C on top of the standard C library, I prefer using a framework or at least a single-header with a list of saner/more modern types and wrappers.
- apaprocki 4y agoExcept we’ve had stdint.h since C99 (23 years now), so we’ve had a byte type for a long time now. Are you saying C99 historically took too long, or that you don’t get what you need from C99?
- stephc_int13 4y agostdint.h was a huge improvement. But uint8_t is kind of ugly compared to "byte". I personally use : byte u16 u32 u64 i32 etc. and u32x4 f32x4 for vectorized/simd types Not perfect but a good-enough compromise that would not take long to understand for anyone reading my code.
- kabdib 4y agoI'm wading through a sea of third party projects right now that variously use uint8_t, u8, byte, tchar, BYTE, and endless variations that prepend one or two underscores for no apparent reason other than simple paranoia. Now, on to other types: Care to guess how many bits WORD is? (Trick question: It depends on the project you're in. You can imagine the adaptation layers when someone thinks that a bool is 32 bits). It's even more fun when they #define these types, rather than use typedef or "using". ("Remember, children, every time you use #define, God kills a startup"). These types don't make things safer, or in any way better. They are long-term damage. For the love of Schmoo, use the standards, I'm losing my hair.