使用 C++ 开发应用程序有哪些优势?与托管语言相比?
您好,我想知道为什么人们用 C++ 开发图书馆应用程序和员工管理应用程序 (这个应用程序),显然同样的事情可以在 C# 和 VB.NET 中以更漂亮的方式完成。甚至银行应用程序也大多是用 C++ 编写的。除了编译后的 C++ 代码执行速度更快之外,还有什么充分的理由吗?
有人能解释一下吗?
Hi I want to know why people develop library applications and employee management applications in C++ (this application, for example), when clearly the same thing can be done in C# and VB.NET in a much prettier way. Even banking applications are mostly in C++. Is there a good reason why, apart from the fact that compiled C++ code executes faster?
Can anyone shed some light on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
C: 1972
C++: 1979
C#: 2000
现在考虑一下库的生命周期,尤其是在银行中,此外,您
还 可以在几乎所有现有计算机系统上(理论上)使用这些库(与 C# 相对)在那里可以找到很多 COBOL (1960)。
C: 1972
C++: 1979
C#: 2000
Now think of the lifetime of a library, especially in a bank, plus, you get to use the libraries (theoretically) on almost every computersystem in existence (as opposed to C#)
You will also still find a lot of COBOL (1960) there.
银行应用程序使用 C++ 的主要原因是:
遗留代码。大型金融公司通常拥有约 10-20-30 年的内部开发的业务特定 C/C++ 库,以及一堆可能不适用于 C#
运行大量金融代码在 Unix/Linux 上。虽然理论上您可以为 Linux 构建 C# 代码,但它绝对不是您想要投入数十亿美元的成熟技术。
The main reasons for C++ for say banking applications is:
Legacy code. A large financial firm typically has ~10-20-30 years of business specific C/C++ libraries developed in-house, plus a bunch of business specific vendor libraries which may not be available for C#
A LOT of that financial code runs on Unix/Linux. While you can purely theoretically build C# code for Linux, it's definitely NOT an established technology you want to bet billion dollar amounts on.
C++ 可在其他类型的系统上使用,而 c# 和 vb.net 则不能。
C++ is usable on other types of systems, whereas c# and vb.net are not.
除了技术原因(例如 C++ 是一种“非托管”语言,其功能和属性与 .NET 语言截然不同)之外,这可能只是由于偏好所致。并非所有人都认为 C# 和 VB.NET 是完成所有任务的最佳工具。或者说是最漂亮的。为什么你这么认为?为什么其他人不能有同样充分的理由来选择他们喜欢的另一种工具呢?
更新,回复康拉德的评论:
“偏好”确实是一个太狭隘的术语,这是正确的。还有其他方面:
经理/老板可以将他们的(可能信息不灵通的)偏好转变为业务政策;
一家公司已有十年历史的代码库可能意味着,在为某些新任务选择编程语言时,您将以不同的视角评估语言。您想要或需要重用现有代码,因此必须能够与旧代码的语言进行互操作。
Apart from technical reasons (such that C++ is an "unmanaged" language with quite different capabilities and properties than .NET languages), this can simply be due to preferences. Not all people find that C# and VB.NET are the best tool for every task. Or the prettiest. Why do you think so? And why should others not have similarly good reasons for choosing another tool of their liking?
Update, in reply to Konrad's comment:
It's correct that "preference" is indeed too narrow a term. There's other facets to it:
Managers / bosses can turn their (possibly badly informed) preferences into business policies;
A corporation's decade-old codebase can mean that when it comes to choosing the programming language for some new task, you'll evaluate languages with a different perspective. You want to or need to reuse the existing code, so interop with the old code's language must be possible.
这可能是特定公司知识经济的一个因素。例如,公司规模越大,或者员工流失率越低,就越难更换能力、流程和工具来适应新语言等。 C/C++ 已经存在相当长一段时间了,许多开发人员以及开发商店都有这样的背景。
关于银行应用程序,我猜原因主要是因为您有一个接近金属的环境,它允许您以可靠的方式利用实时编程。
It might be a factor of the knowledge economy of a particular company. For example, the bigger a company gets, or the less staff turnover they have, the harder it will be to replace competence, process and tooling to accommodate, for example, a new language. C/C++ has been around for quite some time, and many developers as well as development shops have that background.
Concerning banking applications, the reason is, I would guess, mostly because you have a close to metal environment which allows you to utilise realtime programming in a dependable fashion.
每种语言都有其优点和缺点,没有一种语言最适合每种应用程序。 C++ 程序更难编写,但可以利用特定于平台的硬件和功能。因为它们是经过编译的,所以它们的运行速度也往往更快一些。 C#程序更容易编写,但无法访问底层资源,并且不能很容易地移植到非Windows平台。
简而言之,这实际上取决于应用程序的需求。如果您需要原始速度和显式资源管理,请选择 C++。如果您希望编码简单且清晰,请选择 C#。
Every language has its pros and cons and no one language is best for every application. Programs in C++are harder to write, but can take advantage of platform-specific hardware and features. Because they're compiled, they also tend to run a bit faster. C# programs are easier to write, but aren't able to access underlying resources and can't be ported to non-Windows platforms very easily.
In short, it really depends on the application needs. If you need raw speed and explicit resource management, go with C++. If you want ease of coding and clarity, go with C#.