TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

On moving code from C# to F#

93 点作者 blah_blah大约 9 年前

8 条评论

carlosnunez大约 9 年前
I LOVE F#. I wish I could use it more often. I haven&#x27;t used it since I worked at Jane Street three years ago, and Jet.com is the only other place that&#x27;s using it seriously at the moment.<p>It is such an expressive and clear language to write code in. That is until you start needing to use imperative .NET types :)
评论 #11321014 未加载
评论 #11321893 未加载
dgudkov大约 9 年前
We use both C# and F# in our application, using C# for UI (WPF) and F# for data processing with a lot of calls from C# to F# and vice verse. Using F# was crucial, because it allowed writing heavy processing and complex algorithms (e.g. parallel hash aggregation) in a very clean and concise way with higher-level abstractions which saved us a lot of time. Things like not having to deal with null reference exceptions were also a big time-saver. Without F# it would have taken us one more year to release a production-ready application, or even made it impossible at all given the time &amp; budget constrains that we had. If I ever start another project of that scale I will do it using only F#.
MichaelGG大约 9 年前
I&#x27;ve been using F# for a while and it&#x27;s been excellent. It&#x27;s just so less frustrating than writing C# in all its verbosity. There&#x27;s really no reason to not use F# other than legacy or poor management. (Some folks just don&#x27;t &quot;get it&quot;. Perhaps the same kind of people that use a 20 char variable name when 3 would do. Or that are cautious about using local type inference. I don&#x27;t know. But too many people conflate verbosity with readability and get scared.)<p>I tried porting a small demo program, a few hundred lines, directly from C# to F#. It required only 1&#x2F;20th of the type annotations. I&#x27;ve written web APIs in F# and many took about half the lines of code.<p>I particularly like the ease in which I can define local functions to reduce redundancy. In, say, C#, there&#x27;s so much overhead involved that it&#x27;s just not worth it.<p>Going back to F# I&#x27;ve written years ago hasn&#x27;t been hard either. Since the code is so compact, it&#x27;s not difficult to figure things out.<p>F# should be MS&#x27;s flagship. While F# isn&#x27;t perfect (could use more inference, traits or typeclasses, and macros), in terms of tooling, ecosystem, language features it come out near the top.
评论 #11321933 未加载
评论 #11320394 未加载
snizzitch大约 9 年前
The (potential) terseness of F# seems like a bit of a superficial benefit compared to other features of the language, such as discriminated unions and pattern matching, excellent support for immutable records, structural equality by default, computation expressions, etc.<p>I&#x27;m a C# developer with almost a decade of experience, and am pretty enamored with F# as well, but like almost everyone else, am stuck using it solely in my own personal time.<p>However, I&#x27;m not certain how much benefit most teams would gain from using F#, after seeing the average (poor) level to which most developers are able to leverage the C# type system to improve the design of their software. Too many developers are forever stuck in a purely imperative paradigm, only knowing how to type one line of code after another, relying exclusively in enums for &quot;extensibility,&quot; etc. It seems a bit hopeful to convince the community at large to switch to a language with an improved type system in hope that it will be used to create better software.
评论 #11322069 未加载
评论 #11322061 未加载
rtpg大约 9 年前
Is it possible to call F# code easily from C#? Or vice versa?
评论 #11319205 未加载
评论 #11318914 未加载
评论 #11318801 未加载
iuyoynp大约 9 年前
please dont override default scrolling behaviour, the site is unusable
评论 #11318697 未加载
评论 #11320411 未加载
评论 #11319200 未加载
评论 #11321932 未加载
lerax大约 9 年前
Easy, only up 3 tones.
评论 #11321897 未加载
tigershark大约 9 年前
I think that this code can be much simpler, it is really difficult for me to follow it up. I&#x27;m not at all an F# expert, I just studied it a bit for fun last year, but I remember that all the code that I looked at was much more readable..