Forget pointers and embrace copying values

I recently watched an amazing talk by Sean Parent on C++ at :

It’s rather technical (apart from the Photoshop demo around the 54 minute mark) and unfortunately with very bad audio quality. The rather ironic thing is that some of the stuff he is talking about would have been already available for me to use in the Qt C++ framework, which HourGlass uses heavily, but I never fully realized how easy the value semantics and copy-on-write stuff would have been to use. (Because it all seemed too good to be true.) Of course at this point in HourGlass’s lifetime I might not be able to benefit from those techniques so much, as using value semantics is a rather fundamental decision for how code should work. But for any following software projects looking into that stuff will be a must.

There are obviously points against value semantics and copy-on-write. For one, one might be tempted to implement features such as the Photoshop history, which can chew lots of memory when the user uses such features in certain patterns(*). A counterargument to that would be that the user would/should have already been aware that such features simply can’t come for “free”. And isn’t the RAM on modern machines there to be actually used, not to show impressive figures  about how much of it is NOT used…?

The thing I didn’t yet mention is the concepts based polymorphism. Mainly because this is stuff that I didn’t yet try implementing in code myself as it is a bit difficult for me to understand well at this point. (For the value semantics and copy-on-write based stuff I already wrote a neat but useless image manipulation/drawing thing which implements the Photoshop style history brush thing.)


(*) For example if the user consistently makes changes to the current document that change everything in it compared to the current state, there’s nothing to be gained in sharing unchanged data.

This entry was posted in C++, Programming. Bookmark the permalink.

One Response to Forget pointers and embrace copying values

  1. inawe says:

    great work and fascinating video links. thanks man!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s