Why is D unpopular?

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Sun May 1 07:26:03 UTC 2022


On Sunday, 1 May 2022 at 06:48:42 UTC, Walter Bright wrote:
> part of the presentation to make sense. I don't know what 
> "metacode injection" is or what it has to do with CTFE.

There is no need to understand the metastuff, compile time 
evaluation was a bulletpoint and it is referenced from the 
wikipedia page on compile time function evaluation.

> It says "partially implemented", not a prototype. It also seems 
> to have nothing in common with Bjarne's proposal 4 years later.

It was obviously a prototype as it was not part of the language?

> Are you sure D's CTFE does that? (CTFE doesn't allow unsafe 
> code, for example.) Are you sure C++'s does not? D is much more 
> portable between systems than C++ is, in particular things like 
> the sizes of types.

In C++ you use stdint which gives you 3 options for each bit 
width: exact, at least or fast...
Then you bind these in meaningful ways for you application using 
alias, unfortunately C++ does not provide nominal binding, but D 
doesn't offer that either so...

>> Thankfully consteval gives you full control over what happens 
>> when.
>
> That's the C++ rationale for consteval. But D allows 100% 
> control over whether CTFE is run or not. consteval is 
> completely unnecessary. It's simple - CTFE is run if otherwise 
> the compiler would give an error message that it cannot resolve 
> an expression at compile time.

Th difference is that I have functions that I only want to run at 
compile time or runtime, in D you have to test it in the body, in 
C++ you are forced to think about it. But it might be better if 
C++ had a less verbose syntax for this... That is an area where 
you could get an advantage for D, clean up syntax and semantics.

I recently ported some DSP C code that computed the length of 
delay lines twice, that could go wrong if one execution happened 
at compile time and the other at runtime thanks to floating 
point. By being forced to mark it as consteval I can be sure that 
all executions give the same delay length.

> CTFE is conceptually a no-brainer. Run a function at compile 
> time. That's it.

I agree that the concept is trivial, which is why it is 
surprising that people think other languages haven't considered 
this option. The main reason for not executing loops at compile 
time is that compile times become unpredictable/slow for large 
multi-layered applications.




More information about the Digitalmars-d mailing list