tags:

views:

1657

answers:

13

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?

+9  A: 

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.

YGL
You got the nail on the head with that.
BCS
D has direct access to all C libraries. The .h file for them must be converted, but that's usually a straightforward process.
Walter Bright
+4  A: 

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

CharlesB
The split standard library is only an issue with D 1.0. D2 community is solidly around the phobos library.
caspin
Thanks Caspin, fixed it.
CharlesB
Most of the C++0x feature list sound like them playing catch-up with D. And I've not heard anyone say they did a better job of any of it than D does.
BCS
That's how I felt about it. When I first heard about D, I was like "Wow, that sounds way better than C++", but at this point it seems like everything interesting is in C++0x (although sometimes not as elegant). D's array stuff is still cool though.
Brendan Long
D2 is finalizing and new features are coming to a stop.
he_the_great
C++0x won't have the same level of CTFE, nor an ABI, and it's const-correctness won't be of any use for multicore.
ponce
@ponce: what do you mean by "C++0x won't have the same level of ... ABI" ?
Alexander Malakhov
I meant : "C++0x won't have the same level of CTFE, and won't have an ABI".
ponce
@ponce: I'm not an expert and after googling for "C++ ABI problems" I found a lot of pages about compilers incompatibilities (when you're exposing smth more then plain C interface). So how D is better in that regard? Are there more ABI problems, which D addresses ?
Alexander Malakhov
The format of virtual tables and classes is known.Currently a library with C++ linkage is only useable within a program compiled with the same compiler. That's why we still use C linkage for most libraries.
ponce
@ponce: sounds encouraging! Thanks for you time
Alexander Malakhov
+23  A: 

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.

caspin
As a D1.0 user, you may be doing it a bit of a disservice. It's a very good language in its own right (some say better than D2 :)
FeepingCreature
I may be coming down on d1 pretty hard, but for me D2's template system is the killer feature that gives D the edge over C#. My next must have feature is the const system, and it got a major upgrade in D2 as well.
caspin
@Caspin: Templates are where it's at. D templates are so sophisticated that at times the language feels duck-typed, but with the performance and compile time checking of a statically typed language. const is a bit frustrating to use because it's so viral, but on the other hand it actually means something because of its strictness.
dsimcha
I think it would be good to add also link to free chapter on concurrency: http://www.informit.com/articles/printerfriendly.aspx?p=1609144
Alexander Malakhov
+4  A: 

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.

he_the_great
+1  A: 

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

DeadMG
Let me guess - you never tried using it for long. :)
FeepingCreature
@FeepingCreature: Or he's still got a grip on reality. Yes, D seems like a neat language, and yes, it's better than C++ in most ways. Except one **major** problem. It is not compatible with the C and C++ code people already have, and which is the biggest reason why people **use** those languages. Designing a better C++ is a nice idea, but in the process, they threw away the sole advantage C++ actually had. If we don't care about C++ compatibility, there are a dozen langauges I'd rather use than C++ **or** D. I know D acolytes don't like to hear this, but.... :)
jalf
@jalf Personally, although I use C++ for performance reasons, C or C++ compatibility isn't a requirement. I would drop it in a second if a reasonable alternative arose (still looking, btw). OTOH, I understand your point of view, but I don't see how to move forward without dropping baggage.
ergosys
@ergosys: performance? In most cases, C# is as fast or faster. OCaml is often as fast or faster. In many cases, the idea that C++ is "the fastest" is nothing more than a myth.But even in the (rare) cases where C++ is really the only language that can deliver the performance you need, you're absolutely right, dropping legacy baggage would be a good idea. But once again, why stop with D then? Why not create a new language *from scratch with the goal of being fast and efficient? Why settle for a cleaned-up C++?
jalf
D has placed itself awkwardly between two worlds. Some programmers have to stick with C++, and they're not going to switch to D. Others have the freedom to choose the best suited language for their needs, and they don't choose D because they've got so many *other* languages to choose from.
jalf
Because C++ only needs cleaning up. D is the only language that offers more power, unless you can create functionality at runtime. Even some of the most simple template uses in C++ can't be implemented in C# without some incredible crapping around.
DeadMG
@jalf, I am not a D fan, I merely look into it from time to time and then go back to C++. I can't see using C#, as I need portability and it is in the same performance ballpark as Java anyway. I need to do low level things sometimes, C++ lets me do it. C is too primitive, I don't know much about ocaml.
ergosys
@jalf: I'd say D is a long ways off from a cleaned up C++. I'm tempted to assert that the only thing D takes from C++ is a few keywords and some chunks of syntax, but that would be stretching the truth. What is true is that aside from those things, D has never hesitated to dump stuff from C++ if there wan't a good reason to keep it.
BCS
@jalf Agreed in principle, but he specifically spoke of benefits. What you list are drawbacks. It didn't sound like "I'm bound to C++ by legacy and library code", it sounded like "C++ is a good enough _language_ for me" - which people usually stop saying rather quickly after they've used D and gotten used to its little conveniences.
FeepingCreature
+5  A: 

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.

BCS
typo: haskal -> haskell
Alexander Malakhov
+6  A: 

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.

jalf
This ignores the advantages that C and C++ have beyond backwards compatibility. They provide a lower level of abstraction than Lisp or ML, let alone Haskell. Sometimes you want a lower level abstractions but don't care much about backwards compatibility, and D does a very good job providing it. I think there's some painful truth in your criticism of the language, because I think the designers have focused too much on learning from the failures of C and C++ without learning from the successes of other kinds of languages, but their goal isn't fundamentally misguided.
Pillsy
I would also argue that D is trying replace C++, but it does not offer a substantial power level differential. It's C++, but reworked. That's awesome, but.. well, I have C++. And a gigantic pile of libraries. And a gigantic amount of documentation and a huge community. And multiple compilers, which are all hugely mature. And C/C++ compilers for all CPUs that I know of. I don't see how D can compete, or why I should seek out D except for generic breadth learning, *but*, I can learn Lisp, or Prolog, or Haskell, and get my mind blown, instead of C++ Clone #324132. Just my opinion...
Paul Nathan
@Pillsy: True, C/C++ have other advantages, and yes, D does some of those better, but they alone just aren't enough to motivate a large scale migration from C++ to D. Backwards compatibility isn't the *only* reason to use C/C++, but it's a biggie. And it's the one which ensures the languages continued popularity, and so indirectly, it ensures quality compilers/libraries/tools and all the *other* benefits of C/C++.A cleaned-up C++ is nice, but it's just not *enough*. Had it been a cleaned up C++ with C++ compatibility and C++-level maturity and tool/library support, it would have a chance.
jalf
Actually, I think Stroustrup said it best himself. He was asked in an interview a few years ago if there were a lot of things in C++ that he would've done different today, had he had the chance. And he answered something like "no, I did the best I could under the constraints that applied at the time. If I had to do it again today, the result would've been much the same". A better C++ is just not possible, because in trying to make it, you have to violate some of the constraints that C++ follow, and so your language is no longer a replacement for C++. That is D's problem.
jalf
"C#, Python, Ruby, Haskell, SML, Scheme" -- don't know about SML. C# is not portable. Python et al 10x slower. D support for generic programming is great (best?). So those are bad examples. (I'm not saying D is the next big thing, just want more convincing arguments)
Alexander Malakhov
@Alexander: how exactly is D more portable than C#? I can run C# on practically any platform, using Mono. How many platforms have an up-to-date D compiler? Python is slower, yes, but so what? Often, we don't need the speed of C++, and in those cases, such slower languages are perfectly viable alternatives. Feel free to replace C# with Java in that list, if you think that's a better option.
jalf
[C#, Java, compiler] (Keep in mind, I haven't written a single line of D and just read a dozen of threads on their NG)Well, Mono isn't up-to-date either. Java have no low-level access plus in D you have a SafeD which is (memory) safe and is superset of Java.D is on Win, Linux, OS X, FreeBSD. I think up-to-date is only Win, not sure though. But it's only because it wasn't main focus yet. Right now they are polishing last details of lang spec, working on 64 bit and DLL support. Which in my opinion are really more important.
Alexander Malakhov
[Python et al] **1.** I agree it makes no sense whether my GUI responds in 1 or 10 millisec, but there still are a lot of areas where perf matters, right?. **2.** Who said it is impossible to reach 100% of C++ perf with 90% of Python beauty ? Which parts of D do you consider ugly ? And which parts are ugly particularly because of "It tries to be a better designed C++" ?
Alexander Malakhov
[templates] I think it's extremely right thing, that I have to write std::vector and std::sort only once. In this regard D seems to be the only (and better) alternative. **P.S.** I'm really interested in your answers, since erm... I don't want to put effort into another Oberon/Modula (no offence to them)
Alexander Malakhov
+6  A: 

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.

adr
The tool to convert C headers to D headers is http://www.digitalmars.com/d/2.0/htod.html
Walter Bright
+1  A: 

Hi, Henrik.

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

Alex
+21  A: 

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.

Andrei
What do you mean by 'safety', exactly?
Paul Nathan
I mean memory safety, as in you can't have dangling pointers and buffer overruns. D has a safe subset and a system of annotations that allows you to define subprograms and entire programs that are safe.
Andrei
+1 to welcome Andrei Alexandrescu on SO!
CharlesB
+5  A: 

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

JoeCoder
+6  A: 

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.

Justin W
+5  A: 

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.

ponce