News for hackers. Stuff that matters.
Re:C++ and the Culture of Complexity by cageface on Friday August 23, 2013 @07:58PM (#6266926)
The author points out the extra complexity that C++'s programmable value semantics have added to the language without also mentioning the important benefits.

First, you can create a lot of objects on the stack, which avoids any dynamic allocation at all and is far, far faster.

Second, you can precisely control the layout in memory of your data structures. For example, you can represent a set of vertices in an OpenGL scene as a contiguous array of structs. This gives you much, much better cache performance and also makes it easy to hand data directly off to hardware components like graphics cards that need input in memory formatted in specific ways. In languages like Java you have to resort to awkward, inefficient hacks like FloatBuffers to do the same thing.

Re:C++ and the Culture of Complexity by kgabis on Saturday August 24, 2013 @04:39AM (#6268111)
Actualy it might be better (cache-wise) to declare a struct of arrays (SOA) rather than an array of structs (AOS).[1]

[1] http://www.intel.com/content/dam/www/public/us/en/documents/...

Re:C++ and the Culture of Complexity by thebear on Friday August 23, 2013 @11:15PM (#6267449)
Author of blog post here: It's true, I haven't done a good job of mentioning the benefits that you get in return for the complexity of C++, especially as far as value semantics is concerned. Thanks for setting that right.
Re:C++ and the Culture of Complexity by cageface on Saturday August 24, 2013 @02:57AM (#6267944)
I haven't done much C# programming but it looks to me from studying language tutorials that you can have the best of both worlds in many cases in C#. You can have value objects and densely packed arrays of structs if you need them but Java-esque reference semantics everywhere else.