D 是 Java 和 C++ 的可靠替代品吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/146850/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 08:54:47  来源:igfitidea点击:

Is D a credible alternative to Java and C++?

javac++cd

提问by Mark Kegel

Is the D languagea credible alternative to Java and C++? What will it take to become a credible alternative? Should I bother learning it? Does it deserve evangelizing?

d语言一个可靠的替代Java和C ++?怎样才能成为一个可靠的替代方案?我应该费心学习吗?它值得传福音吗?

The main reason I ask is that with the new C++ standard (c++0x) almost here, it's clear to me that the language has gone well past the point of no return with respect to anyone ever understanding it. I know that C/C++ will never die but at some point we need to move on. Even COBOL had its day and Java has in many respects undone C++. So what's next? Does D fill the bill?

我问的主要原因是,随着新的 C++ 标准 (c++0x) 即将到来,我很清楚,对于任何理解它的人来说,该语言已经远远超过了无法回头的地步。我知道 C/C++ 永远不会消亡,但在某些时候我们需要继续前进。甚至 COBOL 也有它的时代,而 Java 在很多方面都取消了 C++。下一个是什么?D 填写账单吗?

采纳答案by dmazzoni

What determines the success and popularity of a programming language for real-world software development is only partially related to the quality of the language itself. As a pure language, D arguably has many advantages over C++ and Java. At the very least it is a credible alternative as a pure language, all other things being equal.

决定一种编程语言在现实世界软件开发中成功和流行的因素仅部分与语言本身的质量有关。作为一门纯语言,D 可以说比 C++ 和 Java 有很多优势。至少,在所有其他条件相同的情况下,作为一种纯语言,它是一种可靠的替代方案。

However, other things matter for software development - almost more than the language itself: portability (how many platforms does it run on), debugger support, IDE support, standard library quality, dynamic library support, bindings for common APIs, documentation, the developer community, momentum, and commercial support, just to name a few. In every one of those regards, D is hopelessly behind Java, C++, and C#. In fact, I'd argue it's even behind so-called "scripting" languages like Python, Perl, PHP, Ruby, and even JavaScript in these regards.

然而,软件开发的其他方面也很重要——几乎比语言本身更重要:可移植性(它在多少平台上运行)、调试器支持、IDE 支持、标准库质量、动态库支持、通用 API 的绑定、文档、开发人员社区、动力和商业支持,仅举几例。在所有这些方面,D 都无可救药地落后于 Java、C++ 和 C#。事实上,我认为它在这些方面甚至落后于所谓的“脚本”语言,如 Python、Perl、PHP、Ruby,甚至是 JavaScript。

To be blunt, you simply can't build a large-scale, cross-platform application using D. With an immature standard library, no support in any modern IDEs(there are plugins for both Visual Studio and Xamarin Studio/MonoDevelop), limited dynamic/shared library support, and few bindings to other languages, D is simply not an option today.

坦率地说,您根本无法使用 D 构建大型跨平台应用程序。由于标准库不成熟,任何现代 IDE 都不支持(Visual Studio 和 Xamarin Studio/MonoDevelop 都有插件),有限动态/共享库支持,并且与其他语言的绑定很少,D 现在根本不是一个选择。

If you like what you see of D, by all means, learn it - it shouldn't take long if you already know Java and C++. I don't think evangelism would be helpful - at this point if D is going to succeed, what it really needs is more people quietly using it and addressing its major shortcomings like standard library and IDE support.

如果您喜欢 D 所见,请务必学习它 - 如果您已经了解 Java 和 C++,应该不会花很长时间。我不认为传福音会有所帮助——在这一点上,如果 D 要成功,它真正需要的是更多的人悄悄地使用它并解决它的主要缺点,如标准库和 IDE 支持。

Finally, as for C++, while most agree the language is too complex, thousands of companies are successfully using C++ as part of a healthy mix of languages by allowing only a smaller, well-defined subset of the language. It's still hard to beat C++ when both raw performance and small memory usage are required.

最后,对于 C++,虽然大多数人都认为该语言过于复杂,但数千家公司通过只允许该语言的一个较小的、定义明确的子集,成功地将 C++ 用作健康语言组合的一部分。当需要原始性能和小内存使用量时,仍然很难击败 C++。

回答by Spodi

D is a good language and decently popular, but like all languages, it is just another tool. Which tool to use depends on the kind of person you are, how you think, the environment you are working in, what restrictions of the languages apply the the program, and most importantly, the program itself. If you have the time, I would definitely recommend learning D. Worst case scenario, you will never use it. More likely you will learn what aspects of it you like the most, and under what conditions it shines brightest, and take advantage of that for when making new programs.

D 是一门很好的语言并且相当流行,但与所有语言一样,它只是另一种工具。使用哪种工具取决于您的类型、您的想法、您工作的环境、应用程序的语言限制,以及最重要的是程序本身。如果你有时间,我肯定会推荐学习 D。最坏的情况下,你永远不会使用它。您更有可能了解您最喜欢它的哪些方面,以及在什么条件下它最闪耀,并在制作新程序时利用它。

I would recommend looking at the D comparison chartto see what the features are for the language and see if it sounds right for you.

我建议您查看D 比较图表,看看该语言的功能是什么,看看它是否适合您。

回答by DarenW

Works great for my own pet projects. I'd use it for employers' projects but for not knowing how hard it would be for them to find someone to take over the source after i move on. There are no technical reasons to avoid it, at least on the supported platforms. (knock on wood)

非常适合我自己的宠物项目。我会将它用于雇主的项目,但不知道在我继续前进后,他们要找到一个人来接管源头有多难。没有技术原因可以避免它,至少在支持的平台上是这样。(敲木头)

回答by DarenW

I like that D is the work of a genius, primarily one mind - Walter Bright, whose Zortech compiler was fantastic in its day.

我喜欢 D 是一个天才的作品,主要是一个人 - Walter Bright,他的 Zortech 编译器在当时非常棒。

In contrast C++ is too much design by committee, even if Bjarne is an influence. Too many add-on features and weird new syntax. This difference reflects in the ease of learning and ease of everyday use, fewer bugs.

相比之下,C++ 是委员会的太多设计,即使 Bjarne 是一种影响。太多的附加功能和奇怪的新语法。这种差异体现在易于学习和易于日常使用,错误更少。

The more coherent languages lead to better productivity and programmer joy - but this is subjective and arguable! (i guess i should vote my own answer down)

更连贯的语言会带来更好的生产力和程序员的乐趣——但这是主观的和有争议的!(我想我应该投票否决我自己的答案)

回答by larsivi

It really depends on what your needs are - large scale commercial applications written in D doexist on the server side, and for that D (typically using Tango/Mango) is a perfect fit, and you are likely to be able to serve more requests than with any other language/platform.

这实际上取决于您的需求 - 用 D 编写的大型商业应用程序确实存在于服务器端,而 D(通常使用 Tango/Mango)非常适合,您可能能够处理更多请求与任何其他语言/平台相比。

For more specialized solutions in terms of protocols and interactivity (which many are) you will have more problems finding the needed libraries, and the lack of tools is likely to affect you more.

对于在协议和交互性(很多都是)方面的更专业的解决方案,您在找到所需的库时会遇到更多问题,而工具的缺乏可能会对您产生更大的影响。

回答by philsquared

I agree that C++ is becoming a dead-end language - and it pains me to say that, after having used it for the last 17 years.

我同意 C++ 正在成为一种死胡同的语言 - 在使用它过去 17 年之后,我很难说这一点。

I think D is the rightful successor to C++. From a language perspective it "does all the right things" (even if I don't agree with every minute decision). I think with C and C++ on the decline there is no other systems level language that can really do what they do, while holding itself up in the world of modern languages - except D! Not only does D fill this role - it excels at it! A look at D1.x should be enough to convince you of that - but when you look at D2.0 it blows you away. It is my opinion that there is no other language around today that works as well as D2.0 in bridging the imperative and functional programming paradigms - which is only going to get more significant in coming years.

我认为 D 是 C++ 的合法继承者。从语言的角度来看,它“做所有正确的事情”(即使我不同意每分钟的决定)。我认为随着 C 和 C++ 的衰落,没有其他系统级语言可以真正做到他们所做的,同时在现代语言世界中保持自己的地位——除了 D!D 不仅担任这个角色 - 它擅长于此!看看 D1.x 应该足以让您相信这一点 - 但是当您查看 D2.0 时,它会让您大吃一惊。我认为,在连接命令式和函数式编程范式方面,当今没有其他语言能像 D2.0 一样有效——这在未来几年只会变得更加重要。

Lack of mainstream acceptance - or even visibility - as well as large scale, mature, libraries - arean obstacle of course. However I don't think you can write it off because of this. I am convinced that D willgrow to become one of the most important languages around within the next few years - and those that are taking it seriously now are going to be well placed to take the lead when that time comes.

缺乏主流接受度——甚至知名度——以及大规模、成熟的图书馆——当然一个障碍。但是,我认为您不能因此而将其注销。我相信 D在未来几年内发展成为最重要的语言之一——而那些现在认真对待它的人将在那个时候处于领先地位。

I think the difference is going to come about due, in large part, to Andrei Alexandrescu's involvement. That's not to discredit Walter Bright in any way, who has done a momentous job in bring D to the world. But Alexandrescu is an important, and compelling, figure in certainly the C++ community - and there's where most of the potential D switchers are going to come from. And he has also made a significant and important contribution to D2.0 in its support for functional programming.

我认为差异将在很大程度上归功于安德烈·亚历山大雷斯库的参与。这并不是要以任何方式诋毁 Walter Bright,他在将 D 推向世界方面做出了重大贡献。但 Alexandrescu 无疑是 C++ 社区中一个重要且引人注目的人物——而且大多数潜在的 D 切换器都来自那里。并且他还为 D2.0 对函数式编程的支持做出了重大而重要的贡献。

It may still turn out that D is doomed to be the Betamax of systems level languages - but my money is on it turning around within the next two years.

事实证明,D 仍然注定要成为系统级语言的 Betamax——但我的钱在未来两年内会转好。

回答by xan

Just to add my own experiences into the mix:

只是将我自己的经验添加到组合中:

About a year ago I worked on a small scale game project (3 coders) lasting 3 months, where we used D as our primary language. We chose it partly as an experiment, partly because it already had bindings for SDL and some other tools we were using, and mostly for the benefits is appeared to have over C++.

大约一年前,我参与了一个持续 3 个月的小型游戏项目(3 名程序员),其中我们使用 D 作为我们的主要语言。我们选择它的部分原因是作为实验,部分原因是它已经绑定了 SDL 和我们正在使用的一些其他工具,而且主要是因为它的好处似乎比 C++ 好。

We loved using it. It was quick to learn and easy to write. Many of it's features proved invaluable, and I miss them having gone back to C++.

我们喜欢使用它。它学起来很快,写起来也很容易。它的许多功能被证明是无价的,我想念它们回到 C++。

However, the following points made our lives more difficult:

然而,以下几点让我们的生活变得更加困难:

  1. There was no good IDE at the time which was a major issue. We ended up making our own by customising Scite. This worked ok, but was not ideal.
  2. There was no debugger at the time. We managed to get WINDBG to work on a hit-or-miss basis, but it was unreliable. Debugging code without a debugger made life hellish at times.
  3. There were 2 standard libraries to choose from at the time (Tango and Phobos). We started with one, switched to the other, and really needed a mixture of features from both (Tangobos!). This caused headaches and some code re-write.
  4. Bindings to other tools not available. In the end we had to switch to DirectX (for reasons I won't get into). There were no bindings for DirectX available so we had to write our own in C++, build it as a .dll and bind to that. This was fairly nasty work and took some time.
  1. 当时没有好的 IDE,这是一个主要问题。我们最终通过定制 Scite 来制作我们自己的。这工作正常,但并不理想。
  2. 当时没有调试器。我们设法让 WINDBG 正常工作,但它并不可靠。在没有调试器的情况下调试代码有时会让生活变得地狱般。
  3. 当时有 2 个标准库可供选择(Tango 和 Phobos)。我们从一个开始,切换到另一个,并且真的需要两者的混合特征(Tangobos!)。这引起了头痛和一些代码重写。
  4. 与其他工具的绑定不可用。最后我们不得不切换到 DirectX(因为我不会介绍的原因)。DirectX 没有可用的绑定,因此我们必须用 C++ 编写自己的绑定,将其构建为 .dll 并绑定到它。这是相当糟糕的工作,需要一些时间。

Overall, we loved to write D. It made actually writing code easy and was quick to learn. The issues I've mentioned echo the answer that has been accepted for this question - it's the "extra" bits that need addressing in D, the core of it is solid.

总的来说,我们喜欢编写 D。它使实际编写代码变得容易并且很快就会学习。我提到的问题与这个问题的答案相呼应——这是需要在 D 中解决的“额外”位,它的核心是可靠的。

回答by gerleim

As a language, I always felt that D is closer to C# than C++. Not in features and libraries, but in "feeling". It's much cleaner,nicer ... fun (than C++). IMHO the biggest obstacle in becoming a credible alternative is tools,IDE and debugger. If D overcomes some obstacles of widespread usage/adoption, more tools and libraries will manifest. (I myself will return to D, if there will be an usable IDE and debugger.)

作为一门语言,我一直觉得D比C++更接近C#。不是在功能和库中,而是在“感觉”中。它更干净、更好……有趣(比 C++)。恕我直言,成为可靠替代品的最大障碍是工具、IDE 和调试器。如果 D 克服了一些广泛使用/采用的障碍,就会出现更多的工具和库。(我自己会回到 D,如果有可用的 IDE 和调试器。)

回答by gerleim

It looks like a very well designed language; much better than C - C++ - Objective C. I can live without an IDE or a debugger for a while, but not without a good, documented library for D 2.0.

它看起来是一种设计精良的语言;比 C - C++ - Objective C 好得多。我可以在没有 IDE 或调试器的情况下生活一段时间,但不能没有 D 2.0 的良好的文档库。

I'll check back in 6 months...

我会在 6 个月后回来查看...

回答by Peter Lawrey

One approach is to search for jobs in your area. Find the jobs you would like to do and see what skills they are asking for. If they are asking for C++ or Ruby or Oracle or D, then that is the skill which is mostly to help you to get the job you want.

一种方法是搜索您所在地区的工作。找到你想做的工作,看看他们需要什么技能。如果他们要求 C++ 或 Ruby 或 Oracle 或 D,那么这些技能主要是为了帮助您获得想要的工作。