Re: Discussing C and C++
Originally Posted by
11jmb
That's a good point. I should have explained myself better. I did not mean to suggest that the two languages are the same. My point was that when people begin to use C++ to match the runtime performance of C, their style becomes more similar to the C style (e.g. raw pointers instead of STL containers). I consider C++ features such as const/inline/new, which admittedly allow for more type safety than #define/#define/malloc, to be a matter of preference rather than a significant shift in style. On the other hand, the OO approach of using "smart pointers" and STL in the C++ style rather than primitives in the C style offers a much sharper contrast. When people really need to squeeze out constants and fit the memory footprint of a small device, the OO approach starts to get in the way, and people opt for the programming style preferred by C developers.
Interestingly enough, I've always preffered to use dynamic arrays to STL containers. I've also never bothered to use smart pointers. And I specifically only use (const wherever convinient) references to pass variables around in place of pointers so that I know not to free them.
I think that'd be why I struggle to see the difference between C and C++. I'm getting a little bit sick of C# though, designed to be hard to do the low level stuff.
By the people, for the people.
Bookmarks