Slow performance compared to C++, ideas?
Steven Schveighoffer
schveiguy at yahoo.com
Fri May 31 08:01:28 PDT 2013
On Fri, 31 May 2013 10:49:21 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> On 5/31/13 9:07 AM, finalpatch wrote:
>> D is very strong at TMP, it provides a lot more tools
>> specifically designed for TMP, that is vastly superior than C++
>> which relies on abusing the templates. This is actually the main
>> reason drawing me to D: TMP in a more pleasant way. IMO one thing
>> D needs to address is less surprises, eg. innocent looking code
>> like v[] = [x,x,x] shouldn't cause major performance hit. In c++
>> memory allocation is explicit, either operator new or malloc, or
>> indirectly through a method call, otherwise the language would
>> not do heap allocation for you.
>
> It would be great if we addressed that in 2.064. I'm sure I've seen the
> report in bugzilla, but the closest I found were:
>
> http://d.puremagic.com/issues/show_bug.cgi?id=9335
> http://d.puremagic.com/issues/show_bug.cgi?id=8449
There was this:
http://d.puremagic.com/issues/show_bug.cgi?id=2356
I know Don has suggested in the past that all array literals be immutable,
like strings, and I agree with that. But it would be a huge breaking
change.
I agree with finalpatch that array literals allocating is not obvious or
expected in many cases.
I wonder if the compiler can prove that an array literal isn't referenced
outside the function (or statement at least), it can allocate it on the
stack instead of the heap? That would be a huge improvement, and good
middle ground.
-Steve
More information about the Digitalmars-d
mailing list