FLTK native in 'D'. Would that be useful?

Dave Dave_member at pathlink.com
Fri Jul 28 13:15:38 PDT 2006

MatthiasM wrote:
> Sean Kelly wrote:
>>> One other note on this <g> If a member function needs to be protected 
>>> or public but is not to be overridden, it can be made 'final'. Then 
>>> the compiler will always call it directly and it can be inlined, etc.
>> Yup.  In general, all C++ functions that are not virtual should be 
>> marked 'final' in D.  Also, any private virtual functions must be made 
>> protected instead.
> I see. I do not want to finalize too many functions, simply because I 

I don't want to leave the impression that D code needs to be 'tuned' to
match C++ in general, I don't think that's the case but the compilers 
are young yet <g> In general the virtual method dispatch is probably 
just as good, it's just that it's on by default so final is low hanging 
fruit if you run into call speed issues.

IMHO, it's easier to write first-cut fast code with D.

> have stumbled over a few functions in FLTK that I would love to have 
> virtual, but can't change it anymore in FLTK1.1.x because we are keeping 
> binary compatibility within a branch, and we are not ready yet to open a 
> true 1.2 ;-)
> Matthias
> PS: I am really interested in what the performance of the "D" code will 
> be. It won't matter too much for FLTK itself, but eventually, should I 
> port my Robotics simulation, performance is a requirement.

Many would be interested in that too...

Don't know if you've seen these or not:


They are trivial but I think it is a good reference for D apps. w.r.t. 
common library functions, etc.

DMD and GDC seem pretty close, w/ DMD maybe being a tad faster for 
integer and GDC for floating point.

The main thing with any D implementation right now is to pre-allocate 
memory if possible before tight loops.

D's easy array slicing makes it easy to do things like:

const char[] s = "hello\n";
const int n = 1_000_000;
const int l = s.length;

char[] str;
for(int i = 0; i < n; i++)
     str ~= s;


char[] str = new char[n * l];
for(int i = 0; i < n; i++)
     str[i*l .. i*l+l] = s;

- Dave

More information about the Digitalmars-d-dwt mailing list