C++ compiler vs D compiler

Cauterite via Digitalmars-d digitalmars-d at puremagic.com
Sat Oct 3 06:29:18 PDT 2015


On Saturday, 3 October 2015 at 10:45:29 UTC, Abdulhaq wrote:
> Perhaps the answer to this is obvious, but what's harder to 
> write from scratch - a C++ compiler or a D compiler? :-)

I suspect writing a C++ compiler would be more difficult, unless 
you takes some shortcuts.
The language's grammar is inherently hard to parse. Its semantics 
are overwhelmingly complex, with countless corner-cases to 
consider for every feature.
Though the first hurdle would be actually reading the standard. 
Last I checked, the C++14 standard was a 1300-page document.

D's situation is far better: context-free grammar, mostly 
straightforward semantics, and I believe it has fewer 
'disruptive' features (those which interact badly with other 
features). Implementing D would still be a huge undertaking, due 
to the sheer quantity of language features, but I imagine there 
would be *far* less tricky parts.

Disclaimer: I have no experience writing compiler backends (and 
limited experience writing frontends).


More information about the Digitalmars-d mailing list