On 14 January 2014 20:25, John Colvin <john.loughran.col...@gmail.com>wrote:
> On Tuesday, 14 January 2014 at 09:07:43 UTC, Manu wrote: > >> Can anyone comment on the codegen when using these statements? Is it >> identical to my reference 'if' statement? >> Liberal use of loops like this will probably obliterate unoptimised >> performance... :/ >> > > In my experience, unoptimised performance will suffer due to the various > function calls and intermediate structs which will be generated naively > as-written. Generic range programming in D depends heavily on optimisers to > denest everything, which gdc and ldc do manage quite successfully. > > Am I correct in thinking that you want (near)playably fast debug builds? I > think that will require some extra thought to achieve in idiomatic D > compared to your usual C++ work. pragma(optimise) anyone? > Sorry, that was 2 separate points although it didn't look like it. The first question was assuming full optimisation, is it equivalent to the if statement I demonstrate with full optimisation in practise? (I'll do some tests, but people must have already experimented in various circumstances, and identified patterns?) The second comment about non-optimised builds; you are correct, it's important that debug builds remain useful/playable. I have worked in codebases where debug builds run in the realm of 1-2 fps, literally unplayable and entirely useless.. This is a MASSIVE productivity hinderance. By contrast, at krome, we took great pride in that our debug build ran at around 10-15fps (actually playable, and quite a unique achievement which did not go unappreciated), which meant we could actually debug complex bugs while still being able to reproduce them. This was almost entirely attributed to our (unpopular) insistence on writing our engine in C instead of C++. Sadly, I don't see D being any better than C++ in this case. It's likely worse than C++, since it's more convenient, and therefore more compelling to use these meta features. I'd like to know if anybody can see any path towards inlined lambda's/literal's/micro-functions in non-optimised builds? I guess the first question is, is this a problem that is even worth addressing? How many people are likely to object in principle?