4 ms·
Uh, not to be That Guy, but what did you expect? Just compare K&R [1] and Stroustrup (any edition) [2] next to each other, and you will get a pretty strong hint
by unwind 4y ago
Uh, not to be That Guy, but what did you expect? Just compare K&R [1] and Stroustrup (any edition) [2] next to each other, and you will get a pretty strong hint of C being a smaller language. That's kind of the point, or it used to feel like it was anyhow.
[1]: https://en.wikipedia.org/wiki/The_C_Programming_Language https://en.wikipedia.org/wiki/The_C_Programming_Language
[2]: https://www.stroustrup.com/4th.html https://www.stroustrup.com/4th.html
- pjmlp 4y agoFirst of all, if you are comparing K&R against Stroustrup, then you should use C++ARM, not later editions. Secondly, Bjarne's books include the overview of the standard library, which neither K&R nor its ANSI C revision do. Third, since everyone keeps using compiler extensions in C, moreso than in C++, those should be included as well.
- masklinn 4y agoBeing a small language is not an excuse. Scheme is a small language, still has dynamic-wind (since R5RS, so no spring chicken). Smalltalk is a tiny language, but has BlockClosure#ensure:. You can have basic safety and QOL features without making the language a monstrous beast. Hell, you can cut old garbage like K&R declarations or digraphs to make room. You can even remove iso646 and most of string.h as a gimme.
- Fredej 4y agoI mean, it's not that I didn't expect changes or didn't expect the language to be smaller - it's just that there definitely things that I would want to bring with me over to C. One thing I really like is RAII - that I can ensure that things are cleaned up in a known, once-defined fashion and I don't have to worry about it everywhere I use a given object. I also generally like using early returns, which is somewhat more complicated with C, as I may need to have more cleanup code around. It can be somewhat mitigated by coding more functionaly and input the necessary parameters to a function, so I can have a different function just doing allocation and deallocation. But still, it's more verbose. `defer` would to some degree solve that issue. Similarly, I've been missing nullptr, just for the expressiveness. I like that C23 now includes it :)