4 ms·
> My favorite C code is the one that has no macros, as few of typedefs as possible, no acrobatics with alloca() or any platform-dependent stuff. You've just ou
by esjeon 4y ago
> My favorite C code is the one that has no macros, as few of typedefs as possible, no acrobatics with alloca() or any platform-dependent stuff.
You've just outlined a perfectly good subset of C. I'm pretty sure people who write C extensively even to this date mostly end up there. The beauty of using C these days is that one gets to control every single byte without going through hoops and loops. Also, any C code can be reliably integrated into other languages using FFI, which is quite universal. So, yeah, no need to create dirty hacks.
- nayuki 4y ago> The beauty of using C these days is that one gets to control every single byte No, not even close: Struct padding, compiling switch as if-else vs. jump, implicit arithmetic promotion to int, stack layout of local variables, and many other issues. If you want to control every byte, write in assembly language.
- chrchang523 4y agoNit: struct padding and arithmetic promotion don't support this point. In practice, C compilers provide struct-packing extensions that cover the uncommon cases where default padding wouldn't yield the layout you want. And they'll let you opt-in to a style where arithmetic promotions are forced to be explicit as they are in e.g. Go. So it would usually be ridiculous to drop down to assembly for either of these reasons today.