Jump to page: 1 2
Thread overview
Unclear about the benefits of D over C++ and Java
Jan 02, 2016
Dibyendu Majumdar
Jan 02, 2016
Rikki Cattermole
Jan 02, 2016
Dibyendu Majumdar
Jan 02, 2016
Guillaume Piolat
Jan 03, 2016
Dibyendu Majumdar
Jan 03, 2016
tsbockman
Jan 03, 2016
Shannon
Jan 05, 2016
Wyatt
Jan 02, 2016
JerryR
Jan 02, 2016
tsbockman
Jan 03, 2016
israel
Jan 03, 2016
rsw0x
Jan 05, 2016
welkam
January 02, 2016
Hi,

I am a long time observer of D but have never done any coding in D. I have considered using D several times but have ended up either going with C++ or Java.

I feel that for someone like me it is not clear what significant advantages D has over C++ or Java to make a switch. I cannot afford to experiment with a language unless I know for certain the benefits of using it.

For instance I would like to know:

* Do D compilers generate more efficient code compared to C++ compilers? Are there performance benchmarks comparing D implementation against C and C++?

* Can D generics do everything C++ templates can (are they Turing complete for instance) - and what additional capabilities does D have that would make a significant difference to the way templates are used in C++?

* How does D's performance compare with Java when it comes to concurrent applications or garbage collection?

* How stable is D? Can one use it without fear that the next version will significantly change the language and therefore one would have to rewrite?

I feel that the D website could do more to explain why someone should move from C++ or Java to D - and this has to be explained in terms of real world benefits in terms of:

* Performance
* Quality of implementation

For someone like me - cool language features don't count that much unless they lead to real world benefits.

My post here was triggered after watching a video by Andrei where he talked about how D generics are different from C++ templates - I think stuff like that needs to be explained in the front page of D website.

Regards
Dibyendu

http://ravilang.org
http://simpledbm.org

January 03, 2016
On 03/01/16 12:31 AM, Dibyendu Majumdar wrote:
> Hi,
>
> I am a long time observer of D but have never done any coding in D. I
> have considered using D several times but have ended up either going
> with C++ or Java.
>
> I feel that for someone like me it is not clear what significant
> advantages D has over C++ or Java to make a switch. I cannot afford to
> experiment with a language unless I know for certain the benefits of
> using it.
>
> For instance I would like to know:
>
> * Do D compilers generate more efficient code compared to C++ compilers?
> Are there performance benchmarks comparing D implementation against C
> and C++?
>
> * Can D generics do everything C++ templates can (are they Turing
> complete for instance) - and what additional capabilities does D have
> that would make a significant difference to the way templates are used
> in C++?
>
> * How does D's performance compare with Java when it comes to concurrent
> applications or garbage collection?
>
> * How stable is D? Can one use it without fear that the next version
> will significantly change the language and therefore one would have to
> rewrite?
>
> I feel that the D website could do more to explain why someone should
> move from C++ or Java to D - and this has to be explained in terms of
> real world benefits in terms of:
>
> * Performance
> * Quality of implementation
>
> For someone like me - cool language features don't count that much
> unless they lead to real world benefits.
>
> My post here was triggered after watching a video by Andrei where he
> talked about how D generics are different from C++ templates - I think
> stuff like that needs to be explained in the front page of D website.
>
> Regards
> Dibyendu
>
> http://ravilang.org
> http://simpledbm.org

Okay so lets start with code efficiency.
We can beat in some cases and match C++ code generation using gdc or ldc. Which use GCC and LLVM backends.

About D templates. Anything can be executed at compile time can be used in templates. You just can't interact with non D code or globals.
Same with e.g. static assert.
Because of this D's meta-programming capabilities beat almost all other languages (Lisp in general is the only set of language that we don't).

Okay, now about general performance and the GC.
If you want performant apps you can't use the GC. It's as simple as that.
The Java and .net crowd like to say otherwise but you just can't. No GC will work as well for memory management quite as like a developer can.

In terms of language changes, you shouldn't need to worry about it too much. Most of the time these days you can go between versions without any changes if you're not pushing the language too much.
It's not like what it was a few years ago.
January 02, 2016
On Saturday, 2 January 2016 at 11:31:24 UTC, Dibyendu Majumdar wrote:
> I feel that for someone like me it is not clear what significant advantages D has over C++ or Java to make a switch. I cannot afford to experiment with a language unless I know for certain the benefits of using it.

If you are truly proficient in C++ then you probably are better off with C++ at this point than using languages like D, Rust or Swift, at least for long term commercial projects.

> * Do D compilers generate more efficient code compared to C++ compilers?

No. The best D compilers use backends written for C/C++ (llvm/gcc).

> * Can D generics do everything C++ templates can (are they Turing complete for instance) - and what additional capabilities does D have that would make a significant difference to the way templates are used in C++?

Certain things are more tedious in C++, like adding methods based on template parameters. Compile time reflection is also more tedious in C++.

Yet again, certain other things look syntactically better in C++ and other things look better syntactically in D.

> * How does D's performance compare with Java when it comes to concurrent applications or garbage collection?

Java has much better garbage collectors. Concurrency frameworks have been more thoroughly tested in Java and C++.

> * How stable is D? Can one use it without fear that the next version will significantly change the language and therefore one would have to rewrite?

Java and C++ are more mature and have been more stable.

January 02, 2016
On Saturday, 2 January 2016 at 11:31:24 UTC, Dibyendu Majumdar wrote:
> I am a long time observer of D but have never done any coding in D. I have considered using D several times but have ended up either going with C++ or Java.
>
> I feel that for someone like me it is not clear what significant advantages D has over C++ or Java to make a switch. I cannot afford to experiment with a language unless I know for certain the benefits of using it.
>
> My post here was triggered after watching a video by Andrei where he talked about how D generics are different from C++ templates - I think stuff like that needs to be explained in the front page of D website.
>

To clarify - the reason for my post here is to raise that the benefits of D over C++ or Java should be explained right up-front on D website in real world terms (i.e. with examples and benchmarks) to help people like me.

Regards
Dibyendu

January 02, 2016
On Saturday, 2 January 2016 at 12:01:20 UTC, Dibyendu Majumdar wrote:
> To clarify - the reason for my post here is to raise that the benefits of D over C++ or Java should be explained right up-front on D website in real world terms (i.e. with examples and benchmarks) to help people like me.

Ok, that is not something I can help you with, but would you trust information provided by the language creators on performance and language feature trade offs?

That said: I really don't think you should consider languages like D and Rust as replacements for Java. If you use Java, you usually have dependencies on frameworks/infrastructure and also a strong preference for garbage collection. Go is closer to being a replacement for small Java projects. D's garbage collector is comparable to the C++ Boehm collector (I think Inkscape uses that).

D is semantically a close cousin of C++, but the standard libraries are different, although inspired by C++ libraries and has adopted C++ terminology. And the template programming semantics are slightly different. Advanced C++ meta programming is more painful than in other languages because it came about as an accident, and even simple things can be demanding and verbose to implement.

D's approach to template programming is pretty straight forward, nothing spectacular and with some syntactical annoyances, but without the really weird C++ SFINAE and inheritance constructs that C++ programmers have to deal with.

D has also implemented some of the features that has been proposed for C++, but not adopted in C++ yet.

Some areas where C++ is better:
- number of available template libraries
- does not have modular arithmetics for signed integers
- somewhat more powerful lambdas
- more flexible operator overloading
- Objective-C++ integration
- better platform support (e.g. asm.js)
- C++17 brings stackless concurrency

Overall, C++ is more verbose than D and that means that  C++ isn't a good language for testing out ideas. D is more suitable for that.

January 02, 2016
On Saturday, 2 January 2016 at 11:31:24 UTC, Dibyendu Majumdar wrote:
> Hi,
>
> I am a long time observer of D but have never done any coding in D. I have considered using D several times but have ended up either going with C++ or Java.
>
> I feel that for someone like me it is not clear what significant advantages D has over C++ or Java to make a switch. I cannot afford to experiment with a language unless I know for certain the benefits of using it.
>
> For instance I would like to know:
>
> * Do D compilers generate more efficient code compared to C++ compilers? Are there performance benchmarks comparing D implementation against C and C++?

Same efficiency if using LDC or GDC, divided by 2 if you use DMD.
But I've found coding in D is more productive (I'd say 2x on small projects vs C++, correct me if you disagree) and you'll be more pleased with the results so you'll have more time and energy to optimize.
C++ has some overhead to create a program so it may lead you to tool less.

> * Can D generics do everything C++ templates can (are they Turing complete for instance) - and what additional capabilities does D have that would make a significant difference to the way templates are used in C++?

The difference is mainly in community, most are very confident with meta-programming, it's not up to single individual in a team to explain static polymorphism to everyone.

To put bluntly, I've never seen a C++ programmer in a team use std::enable_if in years of C++, but every D programmer has written heaps of "static if".
D lets you use static or runtime polymorphism as easily, in C++ it's quite a learning and often people think they don't need it.

That said, it's not all community, there is tangible improvements. Syntax for templates, alias this over multiple inheritance, string mixin over preprocessor macros, static foreach, sane operator overloading and so on.

> * How does D's performance compare with Java when it comes to concurrent applications or garbage collection?

Java have more concurrency primitives and faster garbage collection.
OTOH D runtime is smaller.

> * How stable is D? Can one use it without fear that the next version will significantly change the language and therefore one would have to rewrite?

This won't be a problem. Breaking language changes are rare, and are easy to fix.

> I feel that the D website could do more to explain why someone should move from C++ or Java to D - and this has to be explained in terms of real world benefits in terms of:
>
> * Performance
> * Quality of implementation
>

Can't speak with anyone else, but for me the real reasons are:
- it's fun
- D says "yes" to everything and is not a Big Idea language
- I'm happier with the results, to the point I want to maintain them
- C++ puts you in learning-mode forever. D also does, but without you taking notice :)
- I'm hooked and going back to C++ feels horrible, like for many people here. We need a D rehab center!

At the language level D improves things in all directions: http://p0nce.github.io/d-idioms/#How-does-D-improve-on-C++17?

> For someone like me - cool language features don't count that much unless they lead to real world benefits.

Me too, I care more about shared library support and codegen for example than any language feature.

Yet in some cases they do matter. For example default initialization brings invisible productivity gains you only see when going back to C++.





January 02, 2016
On Saturday, 2 January 2016 at 11:31:24 UTC, Dibyendu Majumdar wrote:
> ...
> * How stable is D? Can one use it without fear that the next version will significantly change the language and therefore one would have to rewrite?
> ...

I recently discover a problem with breakage when trying to compile using a newer version of DMD: http://forum.dlang.org/thread/affaugpppegxuxyoilea@forum.dlang.org

Well I don't know how thing are now in fact, but the above wasn't the first time. And to be honest I already get it that using languages like D, Rust and Go which "still" are growing is a risk when talking about non-breakage.

J.
January 02, 2016
On Saturday, 2 January 2016 at 19:53:04 UTC, JerryR wrote:
> On Saturday, 2 January 2016 at 11:31:24 UTC, Dibyendu Majumdar wrote:
>> ...
>> * How stable is D? Can one use it without fear that the next version will significantly change the language and therefore one would have to rewrite?
>> ...
>
> I recently discover a problem with breakage when trying to compile using a newer version of DMD: http://forum.dlang.org/thread/affaugpppegxuxyoilea@forum.dlang.org
>
> Well I don't know how thing are now in fact, but the above wasn't the first time. And to be honest I already get it that using languages like D, Rust and Go which "still" are growing is a risk when talking about non-breakage.
>
> J.

To clarify: many projects will fail to compile when a new version comes out.

However, you will NOT have to "rewrite" the project. Rather, a few lines across the entire project might have to be updated.
January 03, 2016
On Saturday, 2 January 2016 at 11:31:24 UTC, Dibyendu Majumdar wrote:
> Hi,
>
> I am a long time observer of D but have never done any coding in D. I have considered using D several times but have ended up either going with C++ or Java.
>
> I feel that for someone like me it is not clear what significant advantages D has over C++ or Java to make a switch. I cannot afford to experiment with a language unless I know for certain the benefits of using it.

You know, from the last 2 years that i have followed D, i have come to the conclusion that: If you enjoy programming, use D. If its just your job or because its the standard, stay with C/C++.

because not once have i heard someone say programming in C++ is enjoyable.
But maybe its just me, maybe im too young to know the olden days of the 80s/90s where C++ was a godsend compared to C. Or was it? I dont know, i wasnt alive...
January 03, 2016
On Sunday, 3 January 2016 at 04:25:55 UTC, israel wrote:
> On Saturday, 2 January 2016 at 11:31:24 UTC, Dibyendu Majumdar wrote:
>> Hi,
>>
>> I am a long time observer of D but have never done any coding in D. I have considered using D several times but have ended up either going with C++ or Java.
>>
>> I feel that for someone like me it is not clear what significant advantages D has over C++ or Java to make a switch. I cannot afford to experiment with a language unless I know for certain the benefits of using it.
>
> You know, from the last 2 years that i have followed D, i have come to the conclusion that: If you enjoy programming, use D. If its just your job or because its the standard, stay with C/C++.
>
> because not once have i heard someone say programming in C++ is enjoyable.
> But maybe its just me, maybe im too young to know the olden days of the 80s/90s where C++ was a godsend compared to C. Or was it? I dont know, i wasnt alive...

Ironically, I think C++ has only gotten worse with age and I'm speaking compared to back when there were debates over functions were worth using. In terms of modern C++... I saw nothing of the 'beauty' of C++11 that everyone else somehow saw, all I saw was more cruft to sift through and more "rules" to learn because the language is fundamentally broken.
At some point the C++ committee needs to accept that C++ is approaching unusable levels of complexity, but I guess everyone needs job security.
« First   ‹ Prev
1 2