Comment on Recommended reading: Why mobile web apps are slow (Drew Crawford) by Herb Sutter
@Zeckul: “The equivalent of an array of MyClass in C# would be an array of MyClass* or MyClass& in C++; the equivalent of an array of MyClass in C++ would be an array of MyStruct in C#. Let's not compare apple to oranges.” “Array of MyClass” is exactly an apples-to-apples comparison that shows how the barrel of apples is much smaller on the managed side. In C++ you only need to resort to an array of * or & only when you want polymorphism, for fundamental reasons that would apply to any language. In C# you have to resort to its equivalent for nearly all types. You simply cannot do a true (contiguous) array of any old type in C# or Java. You can in C++. Yes, you can do it for all value types (which can be user-defined types at least in C#) but that’s a small and restricted subset of types that are not useful for all kinds of types — objects must be bitcopyable, you cannot even inherit, etc. They are first-class in a sense, but they are absolutely not general-purpose. When you want an array of arbitrary Objects (cap intentional), including boxed values types, you can’t get it contiguously. To get contiguity, you have to drop down to value types, which is very restrictive and which I correctly said is actively working against an environment and language built around an Object base class of nearly all types — including even boxed value types which can’t be held contiguously. Read More »
Comment on Recommended reading: Why mobile web apps are slow (Drew Crawford) by Zeckul
@HerbSutter: I think that even in an application containing lots of performance-sensitive code, only a small fraction of types need being placed contiguously in arrays for fast access in tight loops. Moreoever these types are typically raw-data-like, i.e. numerical or geometric data for instance. In addition, implementation inheritance would typically not be used for such types anyway because it becomes difficult to understand their memory layout which is kind of the whole point. Note that value types can implement interfaces (and these methods can be called without boxing with proper use of generics). With that said, while you are right to say that value types are limited compared to reference types in .NET, these restrictions are not an issue in the concrete cases where value types are indeed required. I would be curious to see an example to the contrary. Read More »
Comment on Recommended reading: Why mobile web apps are slow (Drew Crawford) by The Curse of Reading and Forgetting : The New Yorker | Glasses
[…] Read more… […] Read More » | ||||
Wednesday, July 17, 2013
Why mobile web apps are slow
Subscribe to:
Comments (Atom)