3 ms·
The 'original sin' of C++ is not having both references and pointers, but trying to remain compatible with C. That means that Stroustrup couldn't have ditched
by unscaled 10y ago
The 'original sin' of C++ is not having both references and pointers, but trying to remain compatible with C.
That means that Stroustrup couldn't have ditched pointers, but if he wanted to implement operator overloading for value types with same efficiency as C he needed some way to support doing that without using pointers directly:
http://www.stroustrup.com/bs_faq2.html#pointers-and-references http://www.stroustrup.com/bs_faq2.html#pointers-and-referenc...
http://stackoverflow.com/questions/8007832/could-operator-overloading-have-worked-without-references http://stackoverflow.com/questions/8007832/could-operator-ov...
A lot of the nastiness of C++ comes from trying to maintain C compatibility: Special behavior for POD, most vexing parse, .h/.cc file split, everything preprocessor and many other misfeatures. Of course, there's also the flip side of it: if C++ wasn't a near-superset of C, it would have never become so popular.
- cmrdporcupine 10y agoYeah I agree that C compatibility is the fail. But it's also the only reason C++ is around today. There were plenty of other compiled systems languages with OO or module systems floated in the 80s, including the quite capable Modula-2/3s, various Pascal dialects, etc. Of all of them only C++ (and Objective-C because iOS) has any relevance today. And likely because there was a kind of path to trendy-OO for existing C programmers and shops.