3 ms·
How about write in C, rather than C++, so you don't force C++ on your users. I mean, if you're going to go so far as to recommend avoiding pointers in your api
by smcameron 7y ago
How about write in C, rather than C++, so you don't force C++ on your users. I mean, if you're going to go so far as to recommend avoiding pointers in your api because your users can't understand them, why in the hell would you then go write a library in C++?
- deleted 7y ago[deleted]
- jcelerier 7y agoUsing values everywhere has less gotchas in c++ - return value optimization is applied much more consistently for instance. Also you can make c++ look not far from python in terms of cognitive overhead for beginners. C ? Not so much
- eska 7y agoIn C return value optimization is not a problem to begin with. There are many more side effects in C++ that could inhibit (have inhibited) return value optimization, by e.g. overloading operators. The standard actually changes the behavior of side effects to allow for return value optimization, i.e. code acts differently depending on whether it's return value optimized or not. I don't feel like any of this is consistent or simpler than C.
- jcelerier 7y ago> In C return value optimization is not a problem to begin with of course it is - https://gcc.godbolt.org/z/welWvd https://gcc.godbolt.org/z/welWvd C gives you O(N) memcpy, C++ gives you O(1) do-stuff-in-place for the exact same code > overloading operators has exactly zero things to do with RVO > I don't feel like any of this is consistent or simpler than C. it produces vastly simpler user code. In years and years of programming in C++ never has "code acts differently depending on whether it's return value optimized or not" been an issue for anyone I know.
- pjmlp 7y agoBecause it is safer than using plain old C, which WG14 refuses to improve its security story. I don't like my IoT devices to be easily p0wned, just because an array went out of bounds.