计算中的C ++或C# [英] C++ or C# in calculations

查看:73
本文介绍了计算中的C ++或C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我要重写包含多个不同计算功能的旧DLL.旧版本是使用VC6完成的,很容易移植到新格式.

但是,大多数使用这些计算的软件都是用C#编写的.因此,从维护的角度来看,最好用C#编写它们.

我可以接受少量的性能降级,但没有什么严重的.从编程的角度来看,计算本身并不困难,只是基本的数学运算.但是它们确实包含许多迭代(> 10M).

因此,如果我仍然坚持使用C ++还是考虑将库转换为C#,我将很想听听大家的意见.目前,由于计算(迭代)的性质,我认为性能不会成为问题. JIT编译器只应参与一次,其余操作基本上都在执行相同的机器代码.有什么想法吗?

预先感谢,

mika

解决方案

取决于用法.如果它不是实时性能的主要业务应用程序,则始终使用C#.如果是电子游戏,那么也许您会考虑使用C ++.当优化不能显着改善用户体验时,我通常更喜欢易于维护的代码,而不是高度优化的代码.他们是一次性交易,还是经常被启动? dll是什么意思,意味着哪种软件?通常,除非它是对延迟敏感的项目(交易,图形密集型),否则至少应根据我的经验,使用C#时应具有良好的性能.

从维护的角度来看,C#更好,因为您团队中的更多开发人员对此很熟悉?如果是这种情况,则需要多长时间修改一次计算和/或dll.如果经常这样,那么转换为C#可以省去您的头痛.

不过,我曾在GUI和表单逻辑全部为C#的项目中工作,而繁重的分析是通过C ++完成的.这对于我们的项目非常有效.除了可维护性之外,还有其他原因要转向C#吗?


另一个要考虑的问题是您的代码是否专有.如果您不希望其他人拥有源,那么也许您应该将其打包在DLL中.如果这样做,那么该语言就不是问题了,因为只有一个人会看到它.


Hi,

I''m about to rewrite an old DLL containing several different calculation functions. The old version is done with VC6 and it''s quite easily portable to newer formats.

However most of the software using these calculations are written in C#. So from the maintenance point of view it would be best to write them in C#.

I can accept a small performance downgrade but nothing severe. The calculations themselves are not difficult from programming point of view, just basic math operations. But they do contain lots of iterations (>10M).

So I would be interested to hear opinions if I should still stick to C++ or could I consider converting the library to C#. At the moment I feel that the performance wouldn''t be an issue because of the nature of the calculations (iterations). JIT compiler should be involved only once and after that the rest of the operations are basically executing the same machine code. Any thoughts?

Thanks in advance,

mika

解决方案

Depends on the usage. If it''s a business application in which real time performance is not much of a concern, C# all the way. If it''s a video game, then maybe you''ll want to consider C++. I usually prefer code that is easy to maintain over code that is highly optimized when the optimization does not significantly improve the user''s experience.


How often are the calculations called? Are they one time deals, or do they constantly get kicked off? What is the dll used for, meaning, what kind of software? In general, unless it is a latency sensitive project (trading, graphics intensive), you should be fine performance wise going to C#, at least based on my experience.

From a maintenance perspective is C# better because more developers on your team are familiar with it? If this is the case, how often would the calculations and/or dll need to be modified. If this is often, then the conversion to C# can save you a headache.

I have though, worked on projects where the GUI and form logic is all C#, while the heavy analysis was done through C++. This worked very well for our projects. Is there any other reason to move to C# other than maintainability?


Another consideration is whether your code is proprietary. If you don''t want others to have the source, then maybe you should keep it packaged it in a DLL. If you do that, the language is a non-issue, since no one but you will see it.


这篇关于计算中的C ++或C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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