Monday, June 11, 2012

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?


Source: Tips4all

13 comments:

  1. 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 (I would like to say that both Eclipse and Visual Studio 2005, 2008, 2010 and 11 support it, through the use of VisualD -LMcSherry), 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.

    ReplyDelete
  2. 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 invaluable, and I miss them having gone back to C++.

    However, the following points made our lives more difficult:


    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.
    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.
    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.
    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.

    ReplyDelete
  3. 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.

    ReplyDelete
  4. 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)

    ReplyDelete
  5. 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.

    ReplyDelete
  6. It really depends on what your needs are - large scale commercial applications written in D do 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.

    ReplyDelete
  7. 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.

    ReplyDelete
  8. D language is modern. No language is perfect, and there is no doubt about this. But languages are born to make life easier. Where D language compared to C++ has lot of good features, in terms of complexity. Many other language combination specialty is involved, which helps coders to code faster, with TOP features introduced by other languages. Please see also:
    for more details about D and other languages


    D vs C++, is the compatibility, where huge C++ languages are involved and requires compatibility with D. D allow already 100% compatibility with C, which is a good win still.
    D vs C++, C++ is my opinion very nice language, but its hard to code, and time consuming, requires more and more experience to get success, but D allow to do the same with simplicity
    D vs C++, i am not sure if C++ does, but D do allow none type restriction variable assignment using "auto", which is good to have a variable dynamic, when require you can make a strict type
    D vs C++, if you have other language experience, you can straight get started with it, it has easy learning road map, and its getting designed by a strong experienced team and company support
    D vs C++, the very nice thing i found of D, is the code style, it gives the look and feel exactly the same like C/C++, while coding it reminds i am doing really modern C/C++ which called D


    There are lot of more good reason for D language, there is no reason to underestimate any language, its always the user choice.

    ReplyDelete
  9. 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)

    ReplyDelete
  10. 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.

    ReplyDelete
  11. It looks like the question has been answered. D is the better language compared with C++.

    The question of whether for practical purposes D has better infrastructure around is secondary.

    In short if they are both brand new languages without any support around them D is the better language, ergo it is the better language.

    ReplyDelete
  12. 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 without a good, documented library for D 2.0.

    I'll check back in 6 months...

    ReplyDelete
  13. 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 D overcomes some obstacles of widespread usage/adoption, more tools and libraries will manifest. (I myself will return to D, if there will be an usable IDE and debugger.)

    ReplyDelete