Is D more complex than C++?

Francisco Almeida francisco.m.almeida at gmail.com
Tue Mar 29 01:22:31 PDT 2011


ToNyTeCh Wrote:

> Nick Sabalausky wrote:
> > "ToNyTeCh" <tt at nospam.net> wrote in message
> > news:imri5l$1ahi$1 at digitalmars.com...
> >> Seriously, I wanna know. How many lines of compiler code does it
> >> take for each (Walt should have the best handle on this, surely)?
> >> The LOC is one parameter, but I don't want just that -- it just came
> >> to mind while typing the overall question. The intricacy of the
> >> compiler is much more important thatn the LOC. (Is D's compiler more
> >> intricate than C++'s?). Any facts, feelings, guesses, whatever, are
> >> all welcomed in response. The complexity in regard to usage would be
> >> a good thing to hear about from users of all levels of experience
> >> (with D and other languages).
> >
> > I've never actually implemented either, and have dealt very little
> > with the soruce for either, but these are my (unreliable) impressions
> > of it:
> > C++ is a complex monster,
> 
> Ah, yes, but I have an incling that D is also.. but it is "just" an 
> incling (read, a pretty good "guess").

D is complex, but not as complex as C++ (my opinion). There is less complexity due to overcoming language limitation than there is in C++.

> > and has a lot of bizarre complexity in
> > areas that really shouldn't need to be so complex.
> 
> It has to appease C programmers (and the C codebase) though. (One must 
> ask if C programmers have a fountain of youth coded up somewhere to hang 
> on so long!).
> 
> > D cleans up much
> > of that.
> 
> Give me 3 examples.

3 examples, excluding CTFE:
1) D does not impose full compatibility with C (i.e., whereas C++ compilers also compile C, a D compiler may link to C binaries, but only compiles a "clean" subset of C). As a result, there are no preprocessor macros in D. Instead, you have the version statement, which is much simpler and organizes your code more.
2) D has cleaner templates syntax as well as semantics: for example, you have a class X(T) syntax which is much clearer for generic classes.
3) My personal favorite, the standard D IO library has a much cleaner syntax than C++. No more shift operators for streams, simple functions with a built-in option for C-style formatted output.

> > But that cleanup gives D room for additional, but "cleaner",
> > things to be added, like CTFE.
> 
> I don't know "CTFE"... Compile Time... something? (Template 
> masturbation?).

CTFE (Compile Time Function Execution), together with other nice things such as the static if statement, actually eliminates template masturbation from the language. The compiler implicitly optimizes and executes functions at compile-time, whenever it can.

> > So they're both complex compared to
> > the average "minimalism"-driven langauge,
> 
> You mean scripting languages? Cuz those are in a separate category. But 
> some level of comparison with those is valid for sure, for they are 
> probably rewriting the rules moreso than the bit-level language 
> endeavors.

This is a matter of opinion, and up for debate. Statically typed languages like D still have their own place. To each their own, I guess.

> > but D makes more effective
> > use of complexity. One "unit of complexity" gives you more benefit in
> > D.
> 
> If that is so, it could be shown. (A little Devil's Advocate).

Read above, and the language documentation. D is designed with the experienced C++ programmer in mind.

> >
> > Of course, this is a D newsgroup, so naturally we're going to be a
> > bit more in favor of D, anyway, FWIW.
> 
> Well the "in the paint" ones, maybe you. But surely most people here have 
> to make a living and program in other languages and I'd be interested in 
> opinions from those rather than the "in the paint" ones. 

You can always ask in other language newsgroups, but always expect some bias, depending on whose "side" the people who answer you are in. :)



More information about the Digitalmars-d mailing list