4 ms·
People often critique C without acknowledging the simplicity and versatility of C as a platform: C always comes ahead when you need to write portable, simple co
by FrozenVoid 8y ago
People often critique C without acknowledging the simplicity and versatility of C as a platform: C always comes ahead when you need to write portable, simple code without dependencies and without overhead(zero-cost abstractions).
Writing big monolithic projects in C is hard, but making dozens of components, libraries and utilities turns out much easier(Unix way) and they can be optimized/combined at every level as tools instead of monolithic parts of a projects, creating lots of code/program reuse scenarios.
C is also simple in terms of code generated, assembler doesn't expand to 1000 lines from 1 line of C. C keeps performance predictable and easy to reason to about.
- blattimwind 8y agoPerformance is basically never easy to reason about unless we're literally talking about 10 line long for loops. Then, maybe. But that's not a typical case for most applications. Writing portable C is genuinely hard. I doubt many people can write significant quantities C89 code that actually does the same thing on GCC and MSVC out of the box (or on LE and BE, or on different pointer models, or on different architectures).
- burfog 8y agoEven MSVC will do C99 these days. C89 is dead. Big-endian is nearly dead, even in consumer network gear. POWER still survives in high-end network gear, and there are some big-business things (think COBOL) still in use. Most people really shouldn't care about big-endian. Weird pointer models are dead. Even in the embedded world it has all gone byte-addressable, single-address-space, without hardware segments. The hardware does exist on x86, but modern systems effectively hide it. The pointer models are ILP32, LP64, and that abomination that Win64 uses. Within reason, even bitfields are now portable. Both gcc and msvc will assign them starting from the LSB. You might need a pragma to pack the bits, but both compilers support that. Speaking of that: lots of pragma is portable now! You can pack. You can do "once".
- blattimwind 8y agoI.e. somewhat portable code that might (and sometimes does) break randomly, because it isn't actually portable, standard C.
- burfog 8y agoIt is actually portable. It isn't 100% standard of course, and almost nothing is. Start with the fact that standard C is unable to have a GUI, unable to make a network connection, and unable to make a plain text editor that can respond immediately to any keystroke other than Enter. You can't even implement the functions to provide those features. Any program using any of those features is fully undefined by the C standard. Any interesting program is thus undefined by standard C.