tags:

views:

5242

answers:

13
+51  Q: 

C++ versus D

Is the D language a credible alternative to Java and C++? What will it take to become a credible alternative? Should I bother learning it? Does it deserve evangelizing?

The main reason I ask is that with the new c++ standard (c++0x) almost here, its clear to me that the language has gone well past the point of no return with respect to anyone ever understanding it. I know that c/c++ will never die but at some point we need to move on. Even COBOL had its day and Java has in many respects undone c++. So what's next? Does D fill the bill?

+8  A: 

D is a good language and decently popular, but like all languages, it is just another tool. Which tool to use depends on the kind of person you are, how you think, the environment you are working in, what restrictions of the languages apply the the program, and most importantly, the program itself. If you have the time, I would definitely recommend learning D. Worst case scenario, you will never use it. More likely you will learn what aspects of it you like the most, and under what conditions it shines brightest, and take advantage of that for when making new programs.

I would recommend looking at the D comparison chart to see what the features are for the language and see if it sounds right for you.

Spodi
+63  A: 

What determines the success and popularity of a programming language for real-world software development is only partially related to the quality of the language itself. As a pure language, D arguably has many advantages over C++ and Java. At the very least it is a credible alternative as a pure language, all other things being equal.

However, other things matter for software development - almost more than the language itself: portability (how many platforms does it run on), debugger support, IDE support, standard library quality, dynamic library support, bindings for common APIs, documentation, the developer community, momentum, and commercial support, just to name a few. In every one of those regards, D is hopelessly behind Java, C++, and C#. In fact, I'd argue it's even behind so-called "scripting" languages like Python, Perl, PHP, Ruby, and even JavaScript in these regards.

To be blunt, you simply can't build a large-scale, cross-platform application using D. With an immature standard library, no support in any modern IDEs, limited dynamic/shared library support, and few bindings to other languages, D is simply not an option today.

If you like what you see of D, by all means, learn it - it shouldn't take long if you already know Java and C++. I don't think evangelism would be helpful - at this point if D is going to succeed, what it really needs is more people quietly using it and addressing its major shortcomings like standard library and IDE support.

Finally, as for C++, while most agree the language is too complex, thousands of companies are successfully using C++ as part of a healthy mix of languages by allowing only a smaller, well-defined subset of the language. It's still hard to beat C++ when both raw performance and small memory usage are required.

dmazzoni
You can build large-scale cross-platform applications, the issue is more with how specialized it needs to be (and how esoteric your platform is).
larsivi
larsivi is correct, if you don't think you can write large-scale cross-platform applications, you are sadly mistaken.
Rayne
saying it has "no support in any modern IDEs" is overstating it a bit. There is support in eclipse. It isn't 1st class yet, but it is there and getting better.
BCS
So which large-scall cross-platform applications have been written in D? Give us examples instead of just saying dominic's answer is wrong.
jalf
Absence of evidence is not evidence of absence.
FeepingCreature
If one makes a positive assertion such as 'there are pink unicorns', one must offer evidence before it is reasonable to accept. Granted, that doesn't mean there are no pink unicorns as @FeepingCreature stated, but simply stating that is not a compelling or valid argument.
JoshD
+1  A: 

Works great for my own pet projects. I'd use it for employers' projects but for not knowing how hard it would be for them to find someone to take over the source after i move on. There are no technical reasons to avoid it, at least on the supported platforms. (knock on wood)

DarenW
+6  A: 

I like that D is the work of a genius, primarily one mind - Walter Bright, whose Zortech compiler was fantastic in its day.

In contrast C++ is too much design by committee, even if Bjarne is an influence. Too many add-on features and weird new syntax. This difference reflects in the ease of learning and ease of everyday use, fewer bugs.

The more coherent languages lead to better productivity and programmer joy - but this is subjective and arguable! (i guess i should vote my own answer down)

DarenW
There's another genius working on it now too - Andrei Alexandrescu. What he has done with D2.0 is, IMHO, at least as astonishing as what Walter has done with D1.x. Between the two of them (not discounting the numerous other contributors) D is becoming a language to be reckoned with. Watch this space
Phil Nash
make that 3 (or more) darn good programmers: Bartosz Milewski
BCS
+5  A: 

It really depends on what your needs are - large scale commercial applications written in D does exist on the server side, and for that D (typically using Tango/Mango) is a perfect fit, and you are likely to be able to serve more requests than with any other language/platform.

For more specialized solutions in terms of protocols and interactivity (which many are) you will have more problems finding the needed libraries, and the lack of tools is likely to affect you more.

larsivi
could you provide an example of such a commercial app ?
Alexander Malakhov
+21  A: 

I agree that C++ is becoming a dead-end language - and it pains me to say that, after having used it for the last 17 years.

I think D is the rightful successor to C++. From a language perspective it "does all the right things" (even if I don't agree with every minute decision). I think with C and C++ on the decline there is no other systems level language that can really do what they do, while holding itself up in the world of modern languages - except D! Not only does D fill this role - it excels at it! A look at D1.x should be enough to convince you of that - but when you look at D2.0 it blows you away. It is my opinion that there is no other language around today that works as well as D2.0 in bridging the imperative and functional programming paradigms - which is only going to get more significant in coming years.

Lack of mainstream acceptance - or even visibility - as well as large scale, mature, libraries - are an obstacle of course. However I don't think you can write it off because of this. I am convinced that D will grow to become one of the most important languages around within the next few years - and those that are taking it seriously now are going to be well placed to take the lead when that time comes.

I think the difference is going to come about due, in large part, to Andrei Alexandrescu's involvement. That's not to discredit Walter Bright in any way, who has done a momentous job in bring D to the world. But Alexandrescu is an important, and compelling, figure in certainly the C++ community - and there's where most of the potential D switchers are going to come from. And he has also made a significant and important contribution to D2.0 in it's support for functional programming.

It may still turn out that D is doomed to be the Betamax of systems level languages - but my money is on it turning around within the next two years.

Phil Nash
C is not on the decline for systems level programming. Linux, Windows, and OS X are all developed in C. Likewise, many micro-controllers and OSes for micro-controllers are programmed using C.
Kevin
I agree with Kevin. In those areas C is just as strong as it always has been.
Bob Somers
I don't think D "does all the right things". The right thing would be to start over from scratch, not try to make a better C++. I think more radical changes are needed to justify a large-scale switch away from C++.
jalf
Kevin: Windows and OS X are not developed in C. Chunks of the kernel are, of course, but Windows uses heaps of C++, and OS X Obj-C. Linux is the only OS I know of where C has been elevated to One True Language-status and nothing else is used.
jalf
C is not on the decline, and it's hard to see how you can justify that claim. C++ might be, however
JamieH
Well, I think C had it's decline a long time ago. It's made somewhat of a comeback (largely thanks to Linux, and a bunch of disillusioned C++ developers). C++ certainly is, as you say (although it has made a mini-comeback in the last couple of years too)
Phil Nash
What constitutes "a look at D1.x"? I looked at pretty much all the freely available information and wasn't impressed. Not impressed enough to actually try it or to buy a book about D. I don't want to look at code examples or at feature laundry lists. I want concepts, explanations, etc.
sellibitze
+31  A: 

Just to add my own experiances into the mix:

About a year ago I worked on a small scale game project (3 coders) lasting 3 months, where we used D as our primary language. We chose it partly as an experiment, partly because it already had bindings for SDL and some other tools we were using, and mostly for the benefits is appeared to have over C++.

We loved using it. It was quick to learn and easy to write. Many of it's features proved invaluabl, and I miss them having gone back to C++.

However, the following points made our lives more difficult:

  1. There was no good IDE at the time which was a major issue. We ended up making our own by customising Scite. This worked ok, but was not ideal.
  2. There was no debugger at the time. We managed to get WINDBG to work on a hit-or-miss basis, but it was unreliable. Debugging code without a debugger made life hellish at times.
  3. There were 2 standard libraries to choose from at the time (Tango and Phobos). We started with one, switched to the other, and really needed a mixture of features from both (Tangobos!). This caused headaches and some code re-write.
  4. Bindings to other tools not available. In the end we had to switch to DirectX (for reasons I won't get into). There were no bindings for DirectX available so we had to write our own in C++, build it as a .dll and bind to that. This was fairly nasty work and took some time.

Overall, we loved to write D. It made actually writing code easy and was quick to learn. The issues I've mentioned echo the answer that has been accepted for this question - it's the "extra" bits that need addressing in D, the core of it is solid.

xan
A: 

As a language, I always felt that D is closer to C# than C++. Not in features and libraries, but in "feeling". It's much cleaner, nicer ... fun (than C++). IMHO the biggest obstacle in becoming a credible alternative is tools, ide and debugger. If some obstacles of widespreading D overcomes, more tools and libraries will born. (I myself will return to D if there will be a usable ide and debugger.)

gerleim
A: 

It looks like a very well designed language; much better than c - c++ - objective c. I can live without an ide or a debugger for a while, but not with a good, documented library for d 2.0.

I'll check back in 6 months...

glen
A: 

Of course I meant not WITHOUT ...

glen
just edit your original post
DoxaLogos
A: 

Now that Qt is LGPL, I don't bother to answer this question.

Vitaly
what ?
I mean, the language itself doesn't matter that much when you compare development tools available. What's out there for D?
Vitaly
there is Qt binding to D http://dsource.org/projects/qtd
Alexander Malakhov
A: 

One approach is to search for jobs in your area. Find the jobs you would like to do and see what skills they are asking for. If they are asking for C++ or Ruby or Oracle or D, then that is the skill which is mostly to help you to get the job you want.

Peter Lawrey
+1  A: 

D is pretty impressive, and Andrei's book about it is well-written. But as others have said, you need the tools and the platform support. GDC may, over time, be the answer to both.

Have you seen this?

"GNU Debugger adds D language support": http://www.linux.com/news/enterprise/biz-enterprise/358956-gnu-debugger-adds-d-language-support

Also, the digitalmars site has pages discussing interfacing to C and C++ (for those libraries you just can't live without). I wonder if there are any tools that, given a C header file, will take a stab at writing the D prototypes.

Personally I wouldn't at this point push for doing a large project in D, but I would use D for in-house tools, getting experience with it and introducing others to it.

AmigoNico