D语言是否具有多个标准库和GC问题? [英] Does the D language have multiple standard libraries and issues with GC?

查看:105
本文介绍了D语言是否具有多个标准库和GC问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道D的成熟度和稳定性,以及它是否可以很好地替代C / C ++。



我知道目前有两种标准库(Phobos和Tango)。还是没有统一的标准库吗?



另外我前段时间听说这些语言在GCed /非GCed代码的边界上存在问题。我在D网站上找不到关于它的任何参考,所以这个问题仍然存在吗?

解决方案

D版本1它既成熟又稳定,肯定有人在实际工作中使用它。 Phobos是D曾经拥有或可能曾经拥有的唯一标准库,但是D1的Phobos缺乏足够的资源,无法创建各种第三方库来填补空白。 Tango是此类库中最大的,也是使用最多的第三方库(因此,即使不是,它也经常被称为第二标准库,而Walter Bright会很快指出它不是)。但是,D1中的Tango和Phobos不能很好地融合在一起(IIRC,因为Tango取代了诸如垃圾收集器之类的一些标准的东西),因此很有可能D1中进行编程的人会在没有Phobos的情况下使用Tango。此外,除了Digital Mars的主要编译器(包括LDC和gdc)之外,D1还受到多种编译器的支持。



D的版本2刚刚达到成熟度和稳定性。他们已经停止对语言进行重大更改,因此您通常不必担心编译器更新会破坏您的一切,就像过去那样,他们仍在确定语言。实际上,它已经足够成熟,以至于Andrei Alexandrescu发布了 D编程语言作为该语言的权威资源,该语言应在文本中保持有效的限制错误(这是我所著的最好的编程语言书之一)我也读过)。但是,仍然有大量的错误修复程序,因此很可能会遇到一个错误,该错误会引起您对特定应用程序的不满。它确实足够成熟和稳定,可以进行实际的工作,但是请注意,它很有可能会遇到错误。



Tango尚未移植到D2,因此,在D2中编程时,它并不是真正的选择。但是,Phobos现在进展顺利。它增加了很多新功能(现在实际上已经有了容器!-Phobos中缺少容器是在D1中使用Tango而不是Phobos的重要原因),并且其中包含了一些非常强大的功能-std.algorithm是特别好。 D处理lambda函数,嵌套函数和函数指针的方式使函数向算法的传递比当前C ++标准容易得多。另外,它已在D2中修复,因此垃圾收集器和Tango复制的其他一些核心内容现在与Phobos分离了。因此,将Tango移植到D2之后,您就可以混合Phobos和Tango代码了-尽管正如先前的回答中指出的那样,Phobos和Tango使用了截然不同的设计理念(Tango非常类似于Java,而Phobos



目前,我不知道从这个角度来看它们会融合得多么好。



相信dmd是唯一有关D2规范的最新编译器,但我相信gdc和LDC D编译器正在做一些工作(尽管这项工作有多活跃,但我没有知道)。此外,Walter Bright目前正在dmd的64位端口上工作,因此相对较早的日子之一,我们将开始进行本机64位编译。



总体,我想说D2已经可以使用了,但是您确实需要意识到,关于bug修复等方面,仍然有很多工作要做。因此,D2肯定准备好用于业余爱好,并且有可能在工作中被认真使用,但是如果您真的需要稳定(例如,如果您是波音公司,并且错误意味着死亡),那么D1可能仍然会更好的选择。当然,关于D2的一件大事要记住,它具有D1所没有的许多功能,因此,除非您确实需要坚如磐石的稳定性,否则D2很有可能会走。幸运的是,它继续成熟并稳定下来,因此毫无疑问,使用D2无疑会更好。



无论如何,D1和D2都是在一般情况下,可以很好地替代C和C ++。他们可以完成C和C ++的工作,并且(尤其是在D2的情况下)可以做得更好。 D可能落后的主要方面是优化程度。在D中有很多代码与在C或C ++中一样快,但是在D上仍然有很多工作要做,因此有很多空间可以对其进行进一步优化,有时在效率方面会落后于C和C ++。 。因此,一般而言,D是有效的,但是如果您确实确实需要尽可能多的效率,那么对于您所需要的效率可能还不够好(尽管可以达到目标)。另外,那里有很多成熟的C和C ++库,而D那里没有可以使用的相同水平的代码。因为可以从D调用C函数,所以任何C代码都可以与D一起使用,并且可以使用某些C ++代码(尽管在将C ++代码与D混合使用时有很多限制),所以不一定要障碍,但这是需要注意的事情。缺少的主要地方是GUI库。 D1有一些,并且D2的GUI库正在做一些工作,但我不认为它们中的任何一个在这一点上都特别成熟。



因此,与所有内容一样,应使用哪种语言取决于您的工作。 D将做大多数事情并将其做好。但是它并不能解决所有问题,而且还在不断成熟。就个人而言,在这一点上,除非我需要为特定项目使用其他功能,否则我将使用D;除非该项目已经用其他内容编写,否则通常不会使用D,并且现在移植它是没有意义的。因此,我强烈建议您使用D,但是您必须仔细研究并使用它,以查看它是否真的会满足您的要求。


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.

这篇关于D语言是否具有多个标准库和GC问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆