View mode: basic / threaded / horizontal-split · Log in · Help
November 02, 2012
D vs C++11
Hello student here,

I have started to learn D a few months ago with Andrei's book (I 
really liked arguments about design decisions), but as the same 
time I was learning new features of C++11, and now I'm really 
confused. (As learning projects, I've done an IRC Bot in D and an 
IPv6 stack in C++11)

D is a great language and introduce a lot of features I really 
like (range, property, UFCS, great metaprogramming, ...) but 
C++11 and the new standard librairy are well supported now.

I have some solid experience with C++, so I know how cumbersome 
C++ could be (C++11 and universal reference ?), but D has a lot 
of features too and (as C++) a slow learning curve.

I would like to konw the point of view of the community about 
C++11 in regard of D ? Is the gap between D and C++11 is getting 
thinner ? Do you think D will keep attracting people while at the 
same time C++11 has more support (debugger, IDE, Librairies, 
Documentation) ?
November 02, 2012
Re: D vs C++11
On 2012-11-02 18:03, "Erèbe" wrote:
> Hello student here,
>
> I have started to learn D a few months ago with Andrei's book (I really
> liked arguments about design decisions), but as the same time I was
> learning new features of C++11, and now I'm really confused. (As
> learning projects, I've done an IRC Bot in D and an IPv6 stack in C++11)
>
> D is a great language and introduce a lot of features I really like
> (range, property, UFCS, great metaprogramming, ...) but C++11 and the
> new standard librairy are well supported now.
>
> I have some solid experience with C++, so I know how cumbersome C++
> could be (C++11 and universal reference ?), but D has a lot of features
> too and (as C++) a slow learning curve.

I would say that D is fairly scalable in it's set of features. You can 
(mostly) program in D as you would in, say, Java. Then you can start 
bringing in more features of the language as you see fit in your own 
comfortable speed.

> I would like to konw the point of view of the community about C++11 in
> regard of D ? Is the gap between D and C++11 is getting thinner ? Do you
> think D will keep attracting people while at the same time C++11 has
> more support (debugger, IDE, Librairies, Documentation) ?

I would absolutely say that the gap is getting thinner. I would mostly 
say that with C++11 C++ has finally started to catch up with D and the 
rest of the world.

-- 
/Jacob Carlborg
November 02, 2012
Re: D vs C++11
Jacob Carlborg:

> I would say that D is fairly scalable in it's set of features. 
> You can (mostly) program in D as you would in, say, Java

D offers most features present in Java, but the relative 
efficiency of some operations is not the same. HotSpot 
de-virtualizes, unroll run-time-bound loops, and most importantly 
has an efficient generational GC (and other newer GCs like G1) 
that changes significantly the efficiency of allocations and 
memory releases. The result is that if you program in D creating 
lot of short lived garbage as you do in Java, you will see a 
low(er) performance. So in D it's better to allocate in-place 
with structs where possible.


> I would absolutely say that the gap is getting thinner. I would 
> mostly say that with C++11 C++ has finally started to catch up 
> with D and the rest of the world.

C++ is a moving target :-)
http://root.cern.ch/drupal/content/c14

Bye,
bearophile
November 02, 2012
Re: D vs C++11
On Friday, 2 November 2012 at 18:34:13 UTC, Jacob Carlborg wrote:

> I would absolutely say that the gap is getting thinner. I would 
> mostly say that with C++11 C++ has finally started to catch up 
> with D and the rest of the world.

Serious? It doesn't even have a "static if".
November 02, 2012
Re: D vs C++11
On Friday, 2 November 2012 at 20:12:05 UTC, so wrote:
> On Friday, 2 November 2012 at 18:34:13 UTC, Jacob Carlborg 
> wrote:
>
>> I would absolutely say that the gap is getting thinner. I 
>> would mostly say that with C++11 C++ has finally started to 
>> catch up with D and the rest of the world.
>
> Serious? It doesn't even have a "static if".

.. and not even an array type, or string type, and the template 
system remains in a semi-useless state in terms of practicality.

But it is true that C++11 has added features that attempt to 
catch up.

I recall being very eager to try the new improvements out as soon 
as they were available, yet soon afterwards I find myself 
investing my time in D.

C++ is permanently bogged down by too much legacy features that 
are difficult to remove or repair, and I'm convinced that C++ 
cannot be fixed without a redesign from the ground up.

D has effectively "fixed" C++ already, so I agree with the claims 
that D can be considered as a good C++ replacement.

Also I expect that D will continue to evolve and improve, so it 
may be that C++ can never catch up.

--rt
November 02, 2012
Re: D vs C++11
On Friday, November 02, 2012 21:12:02 so wrote:
> On Friday, 2 November 2012 at 18:34:13 UTC, Jacob Carlborg wrote:
> > I would absolutely say that the gap is getting thinner. I would
> > mostly say that with C++11 C++ has finally started to catch up
> > with D and the rest of the world.
> 
> Serious? It doesn't even have a "static if".

C++11 definitely makes the gap thinner than it was with C++98/03. That doesn't 
mean that the gap isn't there, and with pretty much anything involving 
conditional compilation, D is way, way ahead of C++11. C++ templates are 
virtually unusable in comparison to D templates. There's no reason that C++ 
couldn't gain those abilities, but even with C++11, it still isn't there yet 
(though at least they finally have variadic templates).

That said, there _are_ some cool things in C++11 that we don't have (e.g. 
async is pretty cool, and while we have some cool threading stuff, we don't 
have anything quite like it yet). So, we can still learn from C++ even if we 
do better than they do in general.

- Jonathan M Davis
November 02, 2012
Re: D vs C++11
On 2012-11-02 21:12, so wrote:

> Serious? It doesn't even have a "static if".

I said the gap is getting thinner, not that is gone. It got foreach, 
some form of CTFE, static assert, lambda to mention a few new features.

-- 
/Jacob Carlborg
November 02, 2012
Re: D vs C++11
On 11/2/2012 2:33 PM, Jacob Carlborg wrote:
> I said the gap is getting thinner, not that is gone. It got foreach, some form
> of CTFE, static assert, lambda to mention a few new features.


No ranges. No purity. No immutability. No modules. No dynamic closures. No 
mixins. Little CTFE. No slicing. No delegates. No shared. No template symbolic 
arguments. No template string arguments. No alias this.
November 02, 2012
Re: D vs C++11
On Fri, 02 Nov 2012 21:25:49 +0100
"Rob T" <rob@ucora.com> wrote:

> On Friday, 2 November 2012 at 20:12:05 UTC, so wrote:
> > On Friday, 2 November 2012 at 18:34:13 UTC, Jacob Carlborg 
> > wrote:
> >
> >> I would absolutely say that the gap is getting thinner. I 
> >> would mostly say that with C++11 C++ has finally started to 
> >> catch up with D and the rest of the world.
> >
> > Serious? It doesn't even have a "static if".
> 
> .. and not even an array type, or string type, and the template 
> system remains in a semi-useless state in terms of practicality.
> 
> But it is true that C++11 has added features that attempt to 
> catch up.
> 
> I recall being very eager to try the new improvements out as soon 
> as they were available, yet soon afterwards I find myself 
> investing my time in D.
> 
> C++ is permanently bogged down by too much legacy features that 
> are difficult to remove or repair, and I'm convinced that C++ 
> cannot be fixed without a redesign from the ground up.
> 
> D has effectively "fixed" C++ already, so I agree with the claims 
> that D can be considered as a good C++ replacement.
> 
> Also I expect that D will continue to evolve and improve, so it 
> may be that C++ can never catch up.
> 

///ditto

To be fair though, asking "C++ vs D" on a D newsgroup is clearly going
to be tilted more towards the D end ;) But yea, personally, I feel that
C++11 is merely playing "catch up", and doing so on a broken leg.

C++ does have the advantage of being almost universally
supported with mature toolchains on pretty much any platform. D's
toolchain is very mature on Linux, OSX and (aside from the
COFF/OMF stuff) Win32, but still needs work for other platforms and
also could use some work for dynamic libs.

So whenever D is a viable option, I always go for it because I find it
to be vastly superior, even to C++11 (which is merely "slightly less
crappy than old C++", IMO). And then when I *have* to use C++, I do so
while wishing I was doing it in D.

FWIW, I did this little writeup (ok, "rant" ;) ) on my opinion of C++
vs D:
https://semitwist.com/articles/article/view/top-d-features-i-miss-in-c
November 02, 2012
Re: D vs C++11
On Friday, 2 November 2012 at 21:53:06 UTC, Walter Bright wrote:
> On 11/2/2012 2:33 PM, Jacob Carlborg wrote:
>> I said the gap is getting thinner, not that is gone. It got 
>> foreach, some form
>> of CTFE, static assert, lambda to mention a few new features.
>
>
> No ranges. No purity. No immutability. No modules. No dynamic 
> closures. No mixins. Little CTFE. No slicing. No delegates. No 
> shared. No template symbolic arguments. No template string 
> arguments. No alias this.

Agree with everything, but D is a hard sell in the enterprise 
given C++'s maturity.
« First   ‹ Prev
1 2 3 4 5
Top | Discussion index | About this forum | D home