Does D have several libraries and problems with the GC?

I am wondering how mature and stable D is, and if this can be a good replacement for C / C ++.

I know that currently there are two standard libraries (Phobos and Tango). Is it all the same that there is no single standard library?

In addition, I heard some time ago that languages ​​have problems at the borders of GCed / non-GCed code. I could not find any links to this on D website, is this problem still true?

+44
d phobos tango
Jul 08 2018-10-10T00:
source share
6 answers

Version 1 of D is mature and stable, and there are definitely people who use it for real work. Phobos is the only standard library that D has ever had or probably has, but D1 Phobos does not have enough different third-party libraries to fill in the blanks. Tango is the largest of these and is the most frequently used third-party library (therefore it is often called the second standard library, although it is not, and Walter Bright will quickly indicate that this is not so). However, Tango and Phobos in D1 do not mix very well (IIRC, because Tango replaces some standard things like a garbage collector), so there is a good chance that someone programming in D1 will use Tango without Phobos. In addition, D1 is supported by several compilers in addition to the main compiler from Digital Mars, including LDC and gdc.

Version 2 D has just reached maturity and stability. They stopped making significant changes to the language, so you usually do not have to worry about everything that breaks down on you with updating the compiler, as it was in the past, while they still nailed the language down. In fact, he is now mature enough that Andrei Alexandrescu released The D Programming Language as the final resource in a language that should remain valid prohibition errors in the text (and this is one of the best books on a programming language that I also read). However, there are still many bug fixes, so it’s quite possible to encounter an error that causes you some annoyance for your particular application. He is definitely mature enough and stable enough to do the real work with him, but keep in mind that you may run into errors.

Tango has not yet been ported to D2, so this is not an option when programming in D2. However, Phobos is going pretty well now. He gets a lot of great additions to it (he actually has containers now! - lack of containers in Phobos is a big reason for using Tango in D1, not Phobos), and it has some really powerful stuff - std.algorithm is especially nice . Method D handles lambda functions, nested functions and function pointers makes it easier to pass flight functions to algorithms more easily than in the current C ++ standard. It has also been fixed in D2, so the garbage collector and some other kernel elements that Tango duplicated are now separate from Phobos. So, once Tango is ported to D2, you can mix the Phobos and Tango code, although, as mentioned in the previous answer, Phobos and Tango use quite different design philosophies (Tango is very Java-like and Phobos makes heavy use of templates and meta-programming with a duck set, not interfaces), so I don’t know how well they will mix from this point of view.

Currently, I believe that dmd is the only compiler that is the last with respect to the specification for D2, but I believe that there is work on the gdc and LDC D compilers (although I do not know how active this work is). In addition, Walter Bright is currently working on a 64-bit dmd port, so in the near future we will get our own 64-bit compilation.

In general, I would say that D2 is ready for use, but you need to know that there is still a lot of work with it related to bug fixes, etc. Thus, D2 is definitely ready for hobby use and potentially serious use at work, but if you really need stability (for example, if you are Boeing and error means death), then D1 is probably still the best choice. Of course, the big thing to keep in mind about D2 is that it has many functions that D1 does not have, so if you really don't need stable stability, then D2 will most likely go. Fortunately, it continues to mature and stabilize, so the time is definitely approaching when there is no question that it is better to use D2.

Despite this, 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) they can probably do it better. The main place that D can fall behind is how optimized it is. There is a lot of code that will be as fast in D as it is in C or C ++, but still a lot of work is done in D, so there are many opportunities for its further improvement, and this will sometimes lag behind C and C ++ for efficiency, So, as a rule, D is effective, but if you really need the same effective efficiency as you can get, this may not be good enough for what you need (although it is). In addition, there are many mature C and C ++ libraries, while D has nowhere near that level of code floating around where you can work. Any C-code can be used with D, since C functions can be called from D, and some of C ++ code can be (although when mixing C ++ code with D) there are many restrictions, so this will not necessarily be an obstacle, but this is what you need to know. The main place where he was missing would be the GUI libraries. There are some for D1, and work is done in the GUI libraries for D2, but I don't think they are particularly mature at the moment.

So, as with everything, which language you should use depends on what you do. D will do most of the things and do them well. But he does not do everything, and he is still ripening. Personally, at the moment, I use D if I do not need to use something else for a specific project, which is not often if the project is not already written in anything else, and it makes no sense to transfer it right now. Therefore, I highly recommend using D, but you will need to examine it and use it to see if it will really do what you want at the moment.

+33
Jul 08 2018-10-18T00:
source share
— -

I recommend using D2 with Phobos. This is where the language is pleasant enough and stable enough to compensate for the occasional frustrations caused by implementation problems.

+27
Jul 09 '10 at 6:41
source share

I know that currently there are two standard libraries (Phobos and Tango), so I assume that there may be people trying to unify them.

Unification is highly unlikely due to differences in licenses. When Tango is ported to D 2.0, you can use it with Phobos, which is not (easy) in D 1.0.

In addition, I heard some time ago that languages ​​have problems at the borders of GCed / non-GCed code. I could not find any links to this on D website, is this problem still true?

I believe that there are only problems if you are not careful with how you manage your memory. If all references to the object allocated by the GC are stored outside the memory areas marked as GC roots, the GC will examine the object without references and delete it.

If I had to choose D as a replacement for C today, what is D (v 1.0 or v 2.0) and what standard library would you suggest?

Phobos and tango go in several different directions. Phobos (in D 2.0) is closely related to the new D2 features. Tango is more functionally packaged and contains modules that are not available in Phobos, for example. Support for HTTP / FTP clients, various cryptography classes, etc. They also follow different design concepts (Phobos is more in demand / meta-programmable, and Tango is very strictly similar to OOP and thus similar to Java in this regard).

+12
Jul 08 2018-10-10T00:
source share

I am wondering how mature and stable D is, and if this can be a good replacement for C / C ++.

I would be wary of using any language that was not yet supported by a standardization body such as ANSI, ISO, or ECMA. This is perhaps an indicator of maturity. However, Java and Delphi, for example, fall into this category, and although I do not use these languages, they could be called "mature."

Another measure may be the quantity and quality of books and articles written for the language. For me, there is one book for D that Andrei Alexandrescu knows about me. He also wrote a long article in the language for Dr. Dobbs, where he specifically addresses the issue of the standard library.

+5
Jul 08 '10 at 16:44
source share

I had good experience writing a small game in D1 with Phobos and SDL, but it was a pretty small project.

In my opinion, D is missing:

  • An official web forum where people can get help and find answers (NOT newsgroups).
  • official repository for many SDKs converted to D (for example, SDL, Gtk, etc. They are often difficult to find and use when they even exist.)
+4
Jul 08 2018-10-10T00:
source share

I do not think that the question of replacing C is whether the potential replacement is “good” or “mature” enough at the theoretical level, but rather practical considerations and the fact that C is “good enough” for what it was used for. If the language does not have built-in embedded environments and runtimes for each major operating system, this is not very practical for what C is used for. The fact that C is a POSIX language is a big part of the whole problem.

Of course, other semi-low level languages, such as D, can have excellent applications in specialized areas. But you are unlikely to see large multi-platform software (web servers, database servers, word processors, web browsers, etc.) written in D, because none of the main OS (and especially all of them) are not Equipped with a D build environment or runtime.

0
Jul 08 2018-10-10T00:
source share



All Articles