F#和C#的CLR是一样的,为什么是F#比C#快 [英] F# and C# 's CLR is same then why is F# faster than C#
问题描述
我很困惑,如果你开导我将不胜感激。 F#使用相同的CLR C#和底层代码是相同的,然后一个人如何可以建议一个函数写在F#比C#时运行速度更快?如果我在C#中只用一成不变的变量和性能要求是尽可能的高,那么为什么使用F#?
I am confused and would appreciate if you enlighten me. F# uses same CLR as C# and underlying code is identical then how can one suggest that a function runs faster when written in F# than C#? If I use only immutable variables in C# and performance needs to be as high as possible then why use F#?
推荐答案
底层代码相同?
怀疑。一般情况下,F#将在其他一些事情速度越来越慢。同样是C#如此。甚至VB。每种语言都有其长处。如果在大部分地区的整体性能加上,它是在编译器。
underlying code is identical? Doubtful. In general, F# will be faster in some things and slower in others. The same is true of C#. Or even VB. Each language has its pluses. If there is an overall performance plus in most areas, it is in the compiler.
如果我在C#中只用一成不变的变量和性能要求是尽可能的高,那么为什么使用F#?
没有理由单独开关性能,如果事实上是有真正的区别,除非PERF是你的问题。至于为什么切换,如果你只使用在C#中的优良特性,我会说:不切换。
If I use only immutable variables in C# and performance needs to be as high as possible then why use F#? No reason to switch for performance alone, if in fact there is a real difference, unless perf is your problem. As far as why switch if you are only using features that are fine in C#, I would say "don't switch".
我喜欢F#。还有一些问题解决了比C#好得多。但是,即使我把它解决好,我不一定切换,因为我要考虑在混合开发的一个问题。目前,我知道在这个组织了解F#东西很少,所以我将不得不作出一个良好的商业案例进行切换。
I like F#. There are some "problems" it solves much better than C#. But, even if I have a problem it solves better, I am not necessarily switching, as I have to consider the developers in the mix. Currently, I know of few in this organization that know anything about F#, so I would have to make a good business case to switch.
最后,你不得不看在业务问题,并确定路径。你必须考虑精益求精的语言作为组合的一部分,但你也必须检查的核心竞争力,等等。
Ultimately, you have to look at the "business problem" and determine a path. You have to consider the "better" language as part of the mix, but you also have to examine core competency, etc.
这篇关于F#和C#的CLR是一样的,为什么是F#比C#快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!