I'm wondering how mature and stable D is, and if it might be a good replacement for C/C++.
I know that there are currently two standard libraries (Phobos and Tango). Is it still the case that there is no unified standard library?
Additionally I heard some time ago that the languages has problems on the boundaries of GCed/non-GCed code. I couldn't find any reference about that on the D website, so is this problem still true?
Version 1 of D is mature and stable, and there are definitely folks who use it for real work. Phobos is the only standard library that D has ever had or likely ever will have, but D1's Phobos is lacking enough that various third-party libraries were created to fill in the gaps. Tango is the largest of these and is the most heavily used third-party library (hence why it frequently gets called a second standard library even though it isn't, and Walter Bright will be quick to point out that it isn't). However, Tango and Phobos in D1 do not mix very well (IIRC because Tango replaces some standard stuff like the garbage collector), so there's a good chance that someone programming in D1 will use Tango without Phobos. Also, D1 is supported by multiple compilers in addition to the primary compiler from Digital Mars - including LDC and gdc.
Version 2 of D is just now reaching maturity and stability. They've stopped making major changes to the language, so you don't generally have to worry about everything breaking on you with a compiler update as was the case in the past while they were still nailing the language down. In fact, it's now mature enough that Andrei Alexandrescu released The D Programming Language as a definitive resource on the language which should stay valid barring errors in the text (and it's one of the best programming language books that I've read too). However, there is still plenty of bug-fixing going on, so it's quite possible to run into a bug which causes you a fair bit of irritation for your particular application. It's definitely mature enough and stable enough to do real work with it, but be aware that it's quite possible to run into bugs.
Tango has not yet been ported to D2, so it's not really an option when programming in D2. However, Phobos is coming along quite nicely now. It's getting a lot of great additions to it (it actually has containers now! - the lack of containers in Phobos being a big reason to use Tango in D1 rather than Phobos), and has some really powerful stuff in it - std.algorithm is particularly nice. The way D handles lambda functions, nested functions, and function pointers makes passing functions to algorithms light-years easier than it is in the current standard of C++. Also, it has been fixed in D2 so that the garbage collector and some other core stuff that Tango was duplicating is now separate from Phobos. So, once Tango has been ported to D2, you'll be able to mix Phobos and Tango code - though as has been pointed out in a previous answer, Phobos and Tango use rather different design philosophies (Tango being very Java-like and Phobos heavily using templates and meta-programming with duck-typing rather than interfaces), so I don't know how well they'll mix from that standpoint.
Currently, I believe that dmd is the only compiler which is up-to-date with regards to the spec for D2, but I believe that there is work being done on the gdc and LDC D compilers (though how active that work is, I don't know). Also, Walter Bright is currently working on the 64-bit port of dmd, so we'll be getting native 64-bit compilation one of these days relatively soon.
Overall, I'd say that D2 is ready for use, but you do need to be aware that there's still plenty of work being done to it with regards to bug fixes and the like. So, D2 is definitely ready for hobby use and potentially for serious use at work, but if you really need stability (like if you're Boeing and a mistake means death), then D1 would likely still be a better choice. Of course, the big thing to remember about D2 is that it has lots of features that D1 doesn't have, so unless you really need rock-solid stability, then D2 is likely the way to go. Fortunately, it continues to mature and stabilize, so the time is definitely approaching when there will be no question that using D2 would be better.
Regardless, both D1 and D2 are good replacements for C and C++ in the general case. They can do what C and C++ do, and (especially in the case of D2) can probably do it better. The main place that D might fall behind is in how well it's optimized. There's plenty of code that will be just as fast in D as in C or C++, but there's still plenty of work being done on D, so there's plenty of room to optimize it further, and it will sometimes lag behind C and C++ for efficiency. So, generally, D is efficient, but if you really need as much efficiency as you can get, it might not yet be good enough for what you need (though it's getting there). Also, there are plenty of mature C and C++ libraries out there while D doesn't have anywhere near the same level of code floating out there to work with. Any C code could be used with D since C functions can be called from D, and some of the C++ code could be (though there are quite a few restrictions when mixing C++ code with D), so that wouldn't necessarily be much of an impediment, but it is something to be aware of. The main place where it's lacking would be GUI libraries. There are some for D1, and there is work being done on GUI libraries for D2, but I don't believe that any of them are particularly mature at this point.
So, as with everything, which language you should use depends on what you're doing. D will do most things and do them well. But it doesn't do everything, and it's still maturing. Personally, at this point, I use D unless I need to use something else for a particular project, which isn't often unless the project was already written in something else, and it doesn't make sense to port it right now. So, I'd highly suggest using D, but you'll have to look into it and use it to see whether it really will do what you want at this point.
I recommend using D2 with Phobos. It's at the point where the language is enjoyable enough and stable enough to make up for the occasional frustrations caused by implementation issues.
I know that there are currently two standard libraries (Phobos and Tango), so I assume that there might be people trying to unify them.
"Unification" is extremely unlikely due to differences in licenses. When Tango will be ported to D 2.0, you will be able to use it alongside Phobos, which isn't (easily) possible in D 1.0.
Additionally I heard some time ago that the languages has problems on the boundaries of GCed/non-GCed code. I couldn't find any reference about that on the D website, so is this problem still true?
I believe there are only problems if you're not careful with how you manage memory. If all references to a GC-allocated object is stored outside the memory regions marked as GC roots, the GC will consider the object unreferenced and will delete it.
If I had to choose D as a C replacement today, what D (v 1.0 or v 2.0) and what standard library would you suggest?
Phobos and Tango are going in somewhat different directions. Phobos (in D 2.0) ties in closely with D2's new features. Tango is more feature-packed, and contains modules which aren't present in Phobos, e.g. HTTP/FTP client support, various cryptography classes, etc. They also follow different design philosophies (Phobos is more imperative/meta-programming-ish, while Tango is very strictly OOP-like, and thus similar to Java in that regard).
I'm wondering how mature and stable D is, and if it might be a good replacement for C/C++.
I would be wary of using any language that was not yet backed by a standards body such as ANSI, ISO or ECMA. That is perhaps an indicator of maturity. That said Java and Delphi for example would fall into that category, and while I do not use those languages, they could probably be described as "mature".
Another measure might be the number and quality of books and articles written for the language. There is one book for D that I am aware of by Andrei Alexandrescu. He has also written a long article on the language for Dr. Dobbs, where he specifically deals with the standard library issue.
I've had a good experience writing a small game in D1 with Phobos and SDL, but it a was a pretty small project.
In my opinion, D lacks:
- an official web forum where people can get help and search for answers (NOT newsgroups)
- an official repository for many SDKs converted to D (for example SDL, Gtk, etc. These are often difficult to find and use, when they exist at all.)
I don't think the question of replacing C is about whether a potential replacement is "good" or "mature" enough on a theoretical level, but rather about practical considerations and the fact that C is "good enough" for what it's used for. Unless a language has complete native build and runtime environments for every major operating system out there, it's not really practical for what C is used for. The fact that C is the language of POSIX is a big part of the whole issue.
Surely other semi-low-level languages like D could have great applications in specialized fields. But you're unlikely to see major multiplatform software (web servers, database servers, word processors, web browsers, etc.) written in D because no major OS (much less all of them) comes with a D build or runtime environment.
来源:https://stackoverflow.com/questions/3205509/does-the-d-language-have-multiple-standard-libraries-and-issues-with-gc