views:

648

answers:

9
+14  Q: 

Impressions of D?

I've checked the tags and there is nothing for D - the programming language from Digital Mars. It is listed 12th on the TIOBE index, just after Ruby, so it must have some following.

Anybody been using this? What are initial impressions?

+1  A: 

Computerworld has an interesting article about D.. Personally I haven't used it, but from what I have heard, it is a decent language (but a language that lacks a good IDE is in my opinion "doomed", at least until it gets it.. :P )

Espenhh
+12  A: 

D is a very good language that tries to be a successor to C++, and succeeds fairly well. I've seen the creator of the language speak; he is very adamant about creating a fun language with the most "useful" features. It is definitely nicer than C++ and places you closer to the machine than C#/Java. It also allows easy linking of C/C++ libraries.

The major features it has over C++/C#/Java:

  • Automatic garbage collection while still allowing RAII idioms (through the scope modifier)
  • auto keyword - automatic type inference when obvious from context (although this is supposed to happend in C++0x)
  • Improved templates. The syntax is slightly uglier to avoid parsing nastiness, but the template system is cleaner and less able to be abused with meta-programming (this could be a negative if you like template meta-programming)
  • A good distinction between "value" classes and actual classes. struct and class are actually different things; struct acts like a stack-allocated data holder, where as class acts like, well, a class (heap allocated, garbage collected, etc)
  • Builtin delegate support, so a nicer syntax than function pointers in C++ and you don't have to write a closure library yourself.
  • Full support for Mixins.

The downsides are that I haven't found a good tool-set for coding in it, but I have yet to do any large projects in it. There are also far less resources and knowledge available on the language, but the faqs are generally excellent.

If you are familiar with Kenta Cho (ABA Games), he does most his windows games in the D language.

hazzen
ahh...comments went live just as I was editing my answer.Anyway, I'd respond here that this list of things aren't advantages over C++. Item #2 is OBE, #3 is not an improvement, #4 is not a feature, but a restriction, and #5 is a red herring because C++ has functors.
Ben Collins
Isn't the scope modifier somewhat like C#'s using?
Tom Hawtin - tackline
#3 - @ Ben Collins - templates in D are majorly improved, why you say not I can't say. @ hazzen - uglyness of syntax is purely subjective, I think opposite than you in this matter.
larsivi
@hazzen, @larsivi: "uglier" - at least not in all cases, compare: `to!int(string)` and `to<int>(string)`
Alexander Malakhov
A: 

My main question that I have yet to have answered satisfactorily is "What do I get from D that I don't get from C++?" ("prettier syntax" is not a valid answer). My less-than-informed take is "nothing of consequence". Additionally, my perception is that you lose a lot by going from C++ to D: extensive tool chains, developer experience, books (and lots of other literature), commercial product support (and other stuff that would amount to FUD because I make some assumptions).

Anyway, like I said, I'm not terribly well-informed about D, but I've yet to come across a compelling reason to become so informed.

@hazzen: thanks for the response. I have responses to that list, but ....I certainly want to avoid turning this into a C++ vs. D discussion instead of just answering the OP.

@jodonnell: you too. first thing I've heard about D that I actually want to look into.

Ben Collins
Arguing that better syntax doesn't matter is kind of silly. If that were true you'd be using C instead of C++, because C++ doesn't really add anything much more than prettier syntax on top of C.But D does have more than just prettier syntax. Biggest difference is probably the garbage collector.
Baxissimo
Much better metaprogramming w/ static if, variadic templates, alias and string template parameters, compile-time function evaluation? Try writing a function that takes N arrays of arbitrary type, sorts the 1st, and sorts the rest in lockstep like PHP array_multisort. Easy in D, impossible in C++.
dsimcha
+7  A: 

D also has pretty good support for contract programming. It lets you define preconditions and postconditions. More details here.

jodonnell
+2  A: 

D seems to be a decent language, but it is stricter than C++ in ways that don't sit well with me:

  • D is too restrictive in heap (de)allocations for me. My company's project involves the use of highly customized memory allocation strategies (writing your own heaps and page allocators) which D will not support.
  • Garbage collection is great - until your process freezes as the thread for a badly designed GC suspends all other threads to trace the allocation graph. For my work, GC has to be optional and non-blocking. And, if you're careful to break circular pointer graphs yourself, refcounting works fine.
crosstalk
GC and allocation strategies, are mostly a question of quality of implementation, in both runtime library and compiler, they are not restrictions in the language per se. I would be surprised if satisfactorily solutions couldn't be found for your problems.
larsivi
+1  A: 

We definitely need to find/create a good IDE for the D Programming Language... Until it gets a good IDE, it will be a marginal programming language.

Shadow_x99
A: 

@Espenhh

The article you mentioned contains a link to IDE/Editor list for D. Whether one of them is a good IDE I don't know.

J.F. Sebastian
A: 

I can tell you that the Eclipse plugin called Descent is the best I've seen so far. I've also done a bit of D development with Code::Blocks, and I was able to build and debug easily enough.

komma8.komma1
+2  A: 

I didn't find this question earlier as it wasn't tagged, here is my take:

The syntax is not about it looking better (although it mostly does), but about convenience. Common programming tasks are just so much more convenient to do, but without using D for a while, you may not see it.

From a design viewpoint, the nicer syntax is also about reducing ambigious parts in the grammar, making D a breeze to parse, and in theory much easier to properly support in tools and leading to higher quality compilers. This of course requires someone doing the actual work, which haven't necessarily happened at the rate many would like.

As for initial impressions, I got those in early 2003, at which point I went "Oh yeah!". See the D tag now for more questions on D.

larsivi