Can nice D code get a bit slow?

Markus marm24 at proton.me
Wed Mar 8 10:49:32 UTC 2023


Hi, sorry for the broad and vague question. I have read in some 
reddit post about benchmarks, that some code didn't use the final 
keyword on methods in a sense that final would make it faster, I 
believe.

I thought, without any D knowledge, it could be that with shorter 
code I might create virtual calls by accident. It might in some 
rare case have an impact on performance, but it might - on the 
good side - be the optimizer of one of the three compilers that 
puts that handling of maybe-virtual calls away or whatever might 
happen.

So, having no clue about D (just bought some books), I wanted to 
ask if nice looking code can become slow, in general. In the 
mentioned case it's just that I like the packaging of functions 
into some sort of scope (OOP) versus the flat C and Go stuff. I 
like OOP for this reason, but now I'm unsure whether I might stay 
out of creating classes at all.

I do like to write 'in' and 'ref' keywords at their places, for 
maybe creating some little speed benefits and safety, but the 
'final' keyword I then might write because I opted in into OOP 
looks, for just the visual reason.

Uh, hope you understand my vague question, sorry about that. I 
found D to be the right place because it's not missing any 
essential feature I know of.

Kind regards


More information about the Digitalmars-d-learn mailing list