3 ms·
The interesting part to me with this, is that for the last 20 years or so there's been a certain strain of C++ development, spurred on by increasing template/me
by vidarh 12y ago
The interesting part to me with this, is that for the last 20 years or so there's been a certain strain of C++ development, spurred on by increasing template/meta-programming support, that have advocated for moving more code to non-member functions, to benefit from improved reuse.
But this has been awkward because it means calling conventions may often be different and functionality that's "mixed in" this way seem far less integrated than functionality that's brought in via inheritance. It's also had the disadvantage that if you ever suddenly needed one of those free-standing functions to depend on internal state of an object, you'd either have to break encapsulation, or break the API (by moving the function into the class), or provide a legacy function to forward to the new API.
This change would make it even more attractive to break out functionality that does not depend directly on the internal state of an object as standalone functions, in effect creating a sort-of "limited class re-opening".
- phkahler 12y ago>> This change would make it even more attractive to break out functionality that does not depend directly on the internal state of an object as standalone functions, in effect creating a sort-of "limited class re-opening". You can already write the functions that way, nobody is stopping you. f(x,y) a function that returns something based on x and y. x.f(y) a method where object type x does something based on y. The second form will have access to private members of x and has some notion of the object doing something. The first form implies that x is just an argument to the function. What I see is C++ going from object oriented to functional - in other words following whats trendy. That said, I think they should take all the lessons learned doing high performance implementations of C++ and start over to create a new language that doesn't suck with all the baggage.
- os_ 12y agoThe problem is that such an effort would produce a cute academic toy with zero traction in the real world. Or looking at it from the other perspective - would you expect that Clang, Chrome, Mozilla folks just rewrite their projects? What about the core infrastructure code that Google/Bloomberg have implemented in C++?
- yohanatan 12y ago> That said, I think they should take all the lessons learned doing high performance implementations of C++ and start over to create a new language that doesn't suck with all the baggage. Oh, you mean Rust (programming language)?