27

Anyone here with experience of the language D?

I was just reading through its presentation at http://www.d-programming-language.org/ and at Wikipedia and it seems like a good (better) alternative to C++.

With good/better I mean that it seem simpler yet it has all the good stuff within C/C++. But without some of the difficulties that make C++ more difficult to learn and use in a good and efficient way.

So anyone with comments/experience with the language D? Performance?

31

I think there are three major areas in which D has something to say:

  1. Concurrency
  2. Safety within a natively-compiled language
  3. Generic and generative programming

There are a few smaller things, such as contract programming and scripting. Many languages have one or two of the above, but neither managed IMHO to push all three simultaneously up as much as D did.

As mentioned by another poster, there's a book "The D Programming Language". Incidentally it is now on the verge of shipping, details at erdani.com.

24

Andrei Alexandrescu wrote the book on D. And you can can read the first few chapters with safari online's rough cuts. Even if you don't have a safari account the first chapter is still available gratis.

That first chapter does a good job showing off some of D's best features.

After reading some of Andrei's stuff and D's feature list I had to try it out. I spent January 2009 writing a game. I must say I'm quite impressed with the language but it has a long way to go.

It compiles insanely fast. The feature list seems hand picked to make Java, C# and C++ look bad. The standard library takes the best parts of the STL and D-ifies them. All around great things.

However, I was disappointed with the lack of direct 64 bit support. It interfaces with C well enough but you need to find 32 bit versions of the libraries if you're running a 64 bit OS (I am). Update: Walter Bright is actively porting DMD the reference compiler to 64 bit. It should be here soon.

The debugger kinda worked and kinda didn't. I had enough troubles with it that I'd be intimidated to go bug hunting in a large application. Then again the awesome unit testing and validation features should make that a very rare occurrence. I never had a tough bug to hunt down, but my application was relatively small.

Library support was still a bit off. I don't care for D 1.0 (it looks like just another C# wannabe). And D2 has been changing (maturing?) so quickly that most 3rd party libs just can't keep up. In particular, I had a hard time with Derelict. I assume it's 1.0 support is great but the 2.0 stuff kept breaking with each new rev of the dmd compiler.

Now that Andrei's book is out, D 2.0 as a language should be much more stable, I plan to take another whack at it this summer.

9

Some of my fellow grad students are writing an exokernel in D. Like you said, D has some cool features. However, compared to C/C++, there is not as much support for D, in terms of libraries, developer tools, etc.

7

As someone who has used D1 for about three years in an industry setting, I can say that I'd be rather lost without it. Coming from a C# background, at first I missed many features--until I realized that D's templating system could implement them even more robustly. For instance, it took me about 45 minutes to mimic C#'s Nullable with any value type.

I'd argue that D1 is industry ready; the company I work for has dozens of proprietary applications written in it, and whenever I have to look at a legacy C++ app I'm really grateful for the decision to switch and port.

6

With good/better I mean that it seem simpler yet it has all the good stuff within C/C++

It doesn't. It has many of the good features of C++. But not all. It is missing the single biggest reason why people write C++ code: backwards compatibility. Most people do not write C++ code because it's the best language. They do it because they've got a large code base written in C or C++, and they need their code to be compatible with that. Or they're using libraries and APIs written for those languages.

If you're willing to give up on C/C++ compatibility, then yes, D is a much nicer language than C++. But so is C#, Python, Ruby, Haskell, SML, Scheme and dozens and dozens of other languages.

If you don't care about C/C++ compatibility, then it's no longer meaningful to compare D to C++. Then you have to compare it to every other language, because every other language would be a valid alternative. And then, in most cases, there's no reason to stick with the C family of languages at all. Then you could go for something modern and high level, rather than going for the incremental improvements that D offers.

D also has a few problems, compared to C++:

Because it's evolving so quickly, and because it doesn't have the same "industry standard" status as C++, there aren't a lot of tools or libraries for it. Compilers for it aren't as widely available as for C++, IDE's are rare, libraries may be written for older versions of the language.

I think D is going to remain a niche language because it tries to solve the wrong problem. It tries to be a better designed C++, which just isn't what the world needs.

If we want better designed languages, we ditch the C family entirely, and go for, say, Python, or Haskell, or Lisp, rather than "yet another incremental improvement over C".

And in the cases where we want portability, we stick with the old, familiar, stable and mature languages: C and C++.

In cases where we want compatibility with legacy C/C?+ code bases, we stick with C or C++, because no other language solves the problem.

There can be little doubt that as a language, seen in isolation, D is far better designed than C++. But that's because it ignores most of the constraints that C++ had to evolve under, and those constraints are the main reason why C++ became popular, and the reason why C++ is still popular.

So if you ask from a theoretical computer science point of view, as someone interested in programming languages, yes, D is great, and compares very well to C++.

If you ask "is D a good replacement for C++", probably not. And I doubt it'll ever become that.

6

To all the people saying D isn't compatible with C, that isn't true. D can call existing C functions with ease. You just copy/paste the prototypes into your D file in an extern(C) block, then call them. There's a tool on the DigitalMars website that can do this automatically in many cases.

C++ is different though. Its interfacing is a bit weak.

6

Let's talk about how these languages feel.

Programming in C++ feels like solving a never-ending amount of convoluted problems. It turns you into a paranoiac, pessimistic and barely productive individual. Refactoring is daunting, and features interact a lot more than you'd want.

Programming in D feels like just implementing things. You somewhat forget about the language. There is lots of small things that let you express flawlessly what you want, despite it's safer. I think Walter Bright makes mature choices in language design and that shows. With every language claiming "C-like performance" in small benchmarks, it feels good to have access to actual native performance in your apps.

Granted, the language moves fast, so eventually it will turn you paranoiac. But you don't have to use every unstable compiler versions that come up.

Problem is: C++ will probably forever be there. And why? There is no easy transition path from C++ to anything else. D isn't that, and Java wasn't either (JNI? LOL).

So my take is: it would be sad to ditch D because of IDE support (this changed a lot) or immaturity (D1 is there). Since months I've never got add any serious problems when upgrading the D1 compiler.

If you can go for D, go for it. It sucks less.

5

It depends on what you want. Most of the issues with it fall into one of two buckets:

  • It's not mature enough (libs, docs, tools, etc.)
  • It's not enough like X (where X, almost without fail, is one of the higher level language like Lisp, Python, F#, haskell, ruby, etc.)

If you can live with a language that's ecosystem is less than mature and that (when you ask it to) doesn't hesitate to show you the bare metal, then you should take a good long look at D.

5

I compiled this list a while back ago.

My background: I've been using D for five years on my own open source game engine (yage3d.net). D isn't for every type of app, but it's been very well suited for this type of thing and I'm glad I chose it over C++.

4

D is quite cool, but not ready for industry adoption. Features are added quite often.

My feeling is that C++0x, with all its new enhancements, will greatly reduce the advantage of D over C++

4

D delivers on its promises with a few draw backs that will be over come with time and adoption. YGL is correct that support is laking: libraries, tools, and even tutorials.

I would like to point out that the website you linked to is dead and the official page is the Digital Mars' website. Also the language has had two versions under development. Version 1.x, which has been receiving only bug fixes since 2007, and version 2.x which has been an experimental branch but is in the stage of finalization for the coming release and book.

I highly suggested browsing around Wiki4D to find out more about D.

In terms of personal use, I enjoy using it in situations where others would normally use a shell script or scripting language and haven't worked on any real large projects with it.

1

I liked a lot of additions in D. However, I think that they've moved too far from C++, and with poor IDE support and such, I'm not sure that D offers enough benefits to move from C++.

1

The BITPROX? Development Environment is an integrated development environment for the D programming language, produced with the D programming language.

You can download the free 30 days trial beta version for the GNU/Linux or Windows platform from http://bitprox.com/en/download.html

I hope you have good experience with the language. Don't hesitate to get support for the D language or the IDE.

So far I had mostly good experience with the language. It's fast, not mature enough but continue to be more stable and good in use.

-- Alex Makhotin