Destroying Common D Myths

    Original text: semitwist.com/articles/article/view/dispelling-common-d-myths
    Reddit: www.reddit.com/r/programming/comments/118y4m/dispelling_common_d_myths

    Introduction


    As a regular user and fan of the D language , I could not help but notice a number of misconceptions and misunderstandings that regularly occur among beginners.

    All these misconceptions are understandable. Many are related to issues that have played an important role in the past, so it is not surprising that these outdated views continue to exist. It seems to me that these are exactly the areas that the D community should explain to other programmers as best as possible. These topics are:

    • There is an IDE for D
    • DSource fades, but D projects are more active than ever
    • Dividing D1 and D2 No More
    • Phobos standard library? But what about Tango?
    • D - open source
    • D allows manual memory management
    • Static typing does NOT mean unproductive


    There is an IDE for D


    There were times when there were hardly any DE-enabled IDEs any more than a commonplace syntax highlighting. But now this is not so. If you like full-fledged development environments, there are three main options, each of which is actively supported:


    DSource fades, but D projects are more active than ever


    With regularity in a couple of months, questions of this kind arise: “D is dead? I went to DSource and all projects looked outdated and unsupported, and the forums were empty. One gets the impression that D is dying. ”

    DSource was a de facto place for hosting projects on D. Note - WAS. Currently, most active projects have moved to Github and Bitbucket. In fact, even repositories with the reference D compiler and standard library have been hosted on Github for over a year now. And during this time, the pace of development has accelerated significantly, and not vice versa.

    There were some attempts to update DSource in order to make it easier to find active projects among the dead (do not forget that any hosting of open-source projects is doomed to collect a lot of abandoned ones over time). But due to the huge popularity that Github and Bitbucket received, the value of the efforts in this direction was considered insignificant.

    Although, I must admit, it saddens me to say such a thing about DSource. I always appreciated this site and at one time its existence was damn necessary and useful for the D1 infrastructure, long before Github and Bitbucket became commonplace for almost every open-source programmer. The site, the network channel and the hosting itself were donated to the D community (and still are!), So it’s unpleasant for me to talk about DSource in the spirit of a panegyric. But in any case, although DSource is almost never used in modern D infrastructure, the language itself is not only very, very alive, it is developing right before our eyes.

    As for the way to search for active projects in D, in addition to commonplace search engines, I would recommend the D Wiki. Yes, I admit, we were far from perfect in maintaining a page with an up-to-date list of projects, but here and now I swear that I will do my bit and will remind other D users to do the same.

    Dividing D1 and D2 No More


    D2 is the current state of affairs. D2 is already considered a stable branch, D1 is a relic of the past. Forget about D1, you don’t even have to stick a stick, it’s dead.

    And when I say “dead” I don’t mean the same kind of death that can be imagined by analogy with Python 2. I mean that almost no one uses D1 anymore. Everything is already on D2, even late. D1 is used little enough that its official support ceases at the end of this year (as announced a year ago). Nobody cares about D1. That's it, period.

    There is only D2.

    (Translator's note: the author got a little excited here with “dead”, rather “no one uses D1 for new projects, this is pure legacy”)

    Phobos standard library? But what about Tango?


    You may have heard of the Phobos vs Tango standoff. Looking back into the past, this was a definite mistake D, but the problem was identified and fixed. In short: Phobos is the standard D library, period. Tango is now an optional and optional, but fully Phobos-compatible library. Something like this.

    But it was not always so. A bit of history for those who are interested:

    Once upon a time, during the youth of D1, long before Andrei Alexandrescu joined the team, the state of the standard Phobos library was far from the best. It was developed from and to by one single person (Walter Bright), who, of course, being the main developer of the language, was too busy working on the language and the compiler. And for a number of reasons, then it was not a full-fledged open-source.

    Therefore, a group of talented developers gathered and decided to fix this problem by creating a full-fledged standard library. She was named Tango and she was so much better than unfinished Phobos that she became the de facto standard.

    Unfortunately, for normal operation, Tango had to replace some of the low-level parts of Phobos related to the runtime environment. Libraries became incompatible - there was no way to use both at the same time. This, of course, became a real nightmare for PR D.

    Meanwhile, Phobos became fully open-source, Andrei Alexandrescu took charge of its development and little by little Phobos became more beautiful and finished. He was pretty damn good in some places, but that didn't help the key issue of Phobos and Tango incompatibility. But fortunately, the D development community heard numerous complaints about the two standard libraries and focused on solving the problem.

    At that time, D2 was developing as the main unstable branch, while D1 became a stable branch in which changes breaking backward compatibility are forbidden. And for D2, all the functionality that created the incompatibility between Phobos and Tango was redesigned and made into a separate entity Druntime. So now both Phobos and Tango use Druntime and are fully compatible. No conflict exists anymore.

    Which one is worth using? Phobos, if you did not have any specific need for Tango functionality. Be that as it may, but Phobos is still a true standard library.

    What can make you turn to Tango? The same reasons as for any additional library: if you prefer its design, as an option. Tango is stylistically much more similar to Java and may be pleasant to those who have come from this language. Or you needed something from Tango , which in Phobos is not commonplace. For example, in Tango realized the fastest in the world of XML parser . At the same time, the XML module from Phobos is one of the things that oh how to take and rewrite from scratch. (Don't worry, the rest of Phobos is just gorgeous.)

    D - open source


    There are 3 main compilers for D:
    • DMD: reference compiler
    • GDC: uses the GCC backend and is in the process of being included in the main GCC package
    • LDC: uses LLVM


    GDC and LDC are the most real open-source, without any but, and even included in the corresponding sections of the repositories of some Linux distributions. The standard library and runtime, Phobos and Druntime are licensed under a Boost license approved by the Open Source Initiative.

    All DMD sources are available on Github . The Front-end, which is also used by the GDC with LDC, has an OSI-approved Artistic license and also a GPL license.

    The only thing that is not formally open-source is the DMD back-end. The reason is that things are used that were licensed by Symantec at one time and Walter cannot just change the license. But the source code is publicly available and pull requests are always welcome. Are you worried about the spread? Not worth it: just ask Walter himself. The license obliges him to ask for permission (Note by the translator: I am glad to advise how to formulate this copywriting incident in Russian normally) , but this is a purely technical formality. Ask him, and then get permission. Not a single case of refusal is yet known. And yes, do not forget, this applies only to DMD, or rather the back-end DMD. Everything else is open-source without any buts, including two full-format compilers, GDC and LDC.

    D - open-source. Not always, but without a doubt it is now.

    D allows manual memory management


    Although D assumes a default garbage collector , it doesn’t mean that you can’t manage it , replace it or remove it altogether , or use manual memory management.

    D has pointers (elegantly limited by memory safe operations in @ safe mode) and direct function calls in C. You have malloc / free at your disposal and you can place anything in the memory thus obtained using emplace . Or try stacked scoped classes . Or reference counters . Or RAII . Plus, now in the development process is a system of custom allocators.

    Static typing does NOT mean unproductive


    D is a statically typed language, but this should not cause you to associate with a C ++ or Java style:
    % cat funWithRanges.d
    import std.algorithm;
    import std.range;
    import std.stdio;
    void main()
    {
    	// All done lazily:
    	auto squares   = sequence!((a,n) => n^^2)(0);
    	auto fibonacci = recurrence!((a,n) => a[n-1] + a[n-2])(1, 1);
    	auto fibEven   = fibonacci.filter!(x => x%2 == 0)();
    	foreach(v; zip(squares, fibonacci, fibEven).take(6))
    		writeln(v[0], "\t", v[1], "\t", v[2]);
    }
    % rdmd funWithRanges.d
    0       1       2
    1       1       8
    4       2       34
    9       3       144
    16      5       610
    25      8       2584
    

    D is not only thoughtful and effective , but also safe and correct .

    Add different useful things for parallel computations , simple templates and metaprogramming tools , as well as different utilities that have become commonplace .

    Also popular now: