TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why Use F#?

223 pointsby adgasfover 6 years ago

31 comments

Barrin92over 6 years ago
In my opinion it&#x27;s honestly the best statically typed general purpose programming language.<p>f# and also Ocaml strike for me the right balance between practicality and correctness (strict by default, no insistence on purity), but still immutable, good concurrency story, functional first with the ability to write imperative code easily, great type inference etc..<p>Given that so many mainstream languages are piece by piece moving into the same direction and adopting the ML family approaches I have no idea why not more people are moving directly to F# or Ocaml.
评论 #18669410 未加载
评论 #18669549 未加载
评论 #18669856 未加载
评论 #18670316 未加载
lihaoyiover 6 years ago
Having used and enjoyed F#, I ended up programming in Scala which is almost the same language, despite the huge superficial differences:<p>- Indentation delimited blocks vs curlies<p>- CLR vs JVM<p>- Whitespace vs Parenthesis for function calls<p>- Currying by default vs currying optional<p>Despite all this, when you actually start coding, it&#x27;s remarkably the same:<p>- Immutability by default, transformations rather than mutation<p>- Less classes with embedded implementation logic, more &quot;dumb&quot; records with external functions<p>- Structural pattern matching<p>- Tagged unions<p>- Type inference<p>- Convenient definition of record&#x2F;struct-like data types with free copy-constructor<p>- Operator overloading<p>- Easy FFI to external libraries in a different paradigm<p>- Easy &quot;dropping down&quot; to mutable, imperative code (e.g. for performance, or interop)<p>- Both have lots of syntactic and semantic warts and corner cases, though few enough you can live with them<p>- Garbage collected, multithreaded, JITed runtime<p>- Both compile to Javascript<p>While every single feature looks totally different on the surface, starting with a totally different syntax, the two languages are more the same than different. If you look at the tutorials linked from that page, all of them can be translated almost line-for-line from F# to Scala (and vice versa: take any random Scala tutorial, and you can trivially translate it line-for-line into F#)<p>Scala brings with it a bigger ecosystem, both in Scala and from the JVM, and better tooling support in general (Both Scala-specific, as well as general JVM tooling which all works with Scala: profilers, debuggers, package managers, ...), and slightly more seamless platform interop (Scala &lt;-&gt; JVM is less jarring than F# &lt;-&gt; C#), which is why I ended up sticking around.
评论 #18669680 未加载
评论 #18669642 未加载
评论 #18669829 未加载
评论 #18669785 未加载
评论 #18669712 未加载
评论 #18671110 未加载
AdeptusAquinasover 6 years ago
Because if you are a top-notch C# dev, F# is just like you normally code but with less brackets and null reference exceptions.<p>Also, you haven&#x27;t experienced implicit typing until you have used F#&#x27;s ridiculously powerful approach to it (relative to C# anyway).
评论 #18669439 未加载
knocteover 6 years ago
I love F# and there&#x27;s only one thing lacking in its ecosystem: not many opensource projects written in it. And I don&#x27;t mean libraries, tools &amp; frameworks, there are tons of those; I mean a real app.<p>But I hope I can break the trend myself: <a href="http:&#x2F;&#x2F;github.com&#x2F;knocte&#x2F;gwallet" rel="nofollow">http:&#x2F;&#x2F;github.com&#x2F;knocte&#x2F;gwallet</a> . If you want to learn F# by contributing to a real opensource project, you have a chance now.
评论 #18669301 未加载
kyleperikover 6 years ago
Can someone please explain to me how you can use F# without each aspect of the development process being a Microsoft technology?<p>Not to be rude, I just honestly want to know. There is quite a bit of hype around C#, F#. But every time there is a comparison to other languages it seems to skip over the fact that you much have a windows computer running Visual Studio which is a big disadvantage to some people. Quite honestly, they are great languages. I just don&#x27;t want to buy in completely to Microsoft
评论 #18669872 未加载
评论 #18670036 未加载
评论 #18669852 未加载
评论 #18669962 未加载
评论 #18670699 未加载
评论 #18669862 未加载
评论 #18671228 未加载
评论 #18669998 未加载
projectramoover 6 years ago
Okay, I have heard many good things about F# so I’ll give the (probably) kind people who work there two tips on how to get more people interested.<p>1. Release an easy to use web framework that deploys easily. (Rails clone)<p>2. Release an IDE which can graph from the command line (R studio or Spyder clone)<p>If you already have these (say a subset of .Net or visual studio &#x2F; vscode) then the tutorials are misleading because they don’t seem the same.
评论 #18669331 未加载
评论 #18669605 未加载
评论 #18669250 未加载
s369610over 6 years ago
Didn&#x27;t see a mention of the fact it can compile to and interop with JS via Fable <a href="https:&#x2F;&#x2F;fable.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;fable.io&#x2F;</a> which is pretty handy
DanielBMarkhamover 6 years ago
Big F# fan here.<p>After going through a dozen languages, and listening in&#x2F;reading scads of debates on languages, I think the author here misses the point.<p>Don&#x27;t get me wrong: the points he makes are valid, and they make for a great language. Where I think the problem is when discussing languages is that <i>languages are an ecosystem</i>. They&#x27;re groups of people, tools, message boards, IDEs, meetups, and so forth.<p>F# is great on the things he mentions, but the real strength is the way F# can take a bunch of dotnet guys and slowly move them towards pure functional programming without there having to be a huge learning curve. Like C#? Like your objects and classes? Fine. Do that. Like you FooBar .NET libary? We&#x27;ve got that too.<p>From your favorite IDE to the places you hang out, it&#x27;s all the same. Just now with functional programming.<p>F#, in my mind, is first and foremost a <i>training language</i>, and I don&#x27;t mean that in a bad way. It exists in an ecosystem where it naturally helps a bunch of devs learn new stuff. (As opposed to most languages that do some core things, then keep adding crap on top year-after-year)<p>Which brings me to my only criticism of the language: we&#x27;re growing a community of wannabe Haskell&#x2F;Erlang guys who are frustrated doing hook-the-wire-up C# in their day jobs. That can lead to language elitism and frustration on everybody&#x27;s part. I&#x27;m not sure how to solve that. It&#x27;s probably a good thing to have devs interested in upping their game. I think that if you want to move on to a more pristine language, you probably should do that. Understanding F# as an intermediate&#x2F;training language for those interested in programming in general is a good way to keep needed context. If you expect it to be something that it&#x27;s not, it&#x27;s going to lead to frustration.
评论 #18671116 未加载
buybackoffover 6 years ago
I used to love F# before .NET Core, but then it was broken for two years for any sane design time experience on Core. I even wrote some rant about it with specific concerns I had (<a href="http:&#x2F;&#x2F;hotforknowledge.com&#x2F;2016&#x2F;10&#x2F;19&#x2F;4-functional-for-thought-imperative-for-hacking&#x2F;" rel="nofollow">http:&#x2F;&#x2F;hotforknowledge.com&#x2F;2016&#x2F;10&#x2F;19&#x2F;4-functional-for-thoug...</a>).<p>Two years later.. and very recently the .NET Core story started to work well, tooling improved to quite workable state, and in combination with C# it&#x27;s very strong mix of practicality&#x2F;performance + complex flexible abstractions and correctness.<p>Over that time F# has added quite a lot of low-level performance features (on par with C# - Span&#x2F;Memory&lt;T&gt;, ref structs, struct tuples&#x2F;unions, voidPtr, etc) and they <i>just work</i>. Build time is probably the main concern now, I have to disable building F# projects when they are in a solution but not touched because even on i7-8700&#x2F;16GB it&#x27;s very noticeable.<p>Two weeks ago I needed text parser and picked familiar FParsec. It&#x27;s one of the fastest one in .NET (including C# ones) and is a mix of C# for low-level stuff and F# for powerful abstractions. I refactored it quite substantially and tooling was finally nice. But my attempts to micro-optimize it yielded only in substantially reduced GC due to the support of value structs and Span&lt;T&gt;, throughput was already quite optimal from .NET perspective (only c.&lt;5% gain probably due to GC), so if used with care F# could be as fast as C# (which BTW is native-like fast when also used with care).<p>I believe such mix is the winning combination: C# is best for low-level high performance stuff, F# is best for complex things such as recursive data structures, analytics and so one.<p>My big concern is that F# community is great but often F#-only focused, e.g. reinventing existing C# libraries just because it&#x27;s not F#. This isolationism from .NET as a uniform platform led for example to things such as F#&#x27;s `async` is better than Task Parallel Library (C#&#x27;s async&#x2F;await machinery) in theory&#x2F;design, but TPL is so much superior is usability, performance and deep platform integration but F# cannot use it directly. Without native TPL `task{}` F# is not a fully-featured .NET Core citizen but a niche language for specific tasks where it shines, e.g. to write a AST parser for a new query language. Sad that MSFT invests so little in F#, but the language is definitely is alive, is improving and is worth using.
评论 #18670371 未加载
seanmcdirmidover 6 years ago
Someone who worked on F# once told me that one reason F#&#x27;s uptake was limited was because C# was so good at stealing its best features.
评论 #18670497 未加载
评论 #18670689 未加载
jchendyover 6 years ago
&gt; &#x2F;&#x2F; no curly braces, semicolons or parentheses<p>Is this a good thing? It feels like saying &quot;It&#x27;s English without the periods or line breaks or capital letters.&quot;
评论 #18669591 未加载
评论 #18670357 未加载
评论 #18669600 未加载
评论 #18670716 未加载
评论 #18669999 未加载
smt88over 6 years ago
I&#x27;ve read on HN that F# doesn&#x27;t get nearly as much attention and support from Microsoft as C# does, to the point where people expressed concern that F# might be put into maintenance mode.<p>Does anyone reading this feel that way, or was it just FUD?
评论 #18670540 未加载
评论 #18672840 未加载
评论 #18669721 未加载
评论 #18669766 未加载
ssijakover 6 years ago
How does F# compare to Haskell? I wan`t to put one staticaly typed functional language under my belt and I do like what I read about F# but I do not like it`s windows&#x2F;microsoft ecosystem. I`ll probably go with Haskell.
评论 #18670882 未加载
评论 #18670833 未加载
dzongaover 6 years ago
Been learning F# the last two months. Wanted to learn Ocaml first. But F# is the sweet spot, beautiful functional syntax . Can leverage the now open .Net Ecosystem + pretty fast for doing financial stuff that I wanna do.
Nelkinsover 6 years ago
My startup, <a href="https:&#x2F;&#x2F;masse.app" rel="nofollow">https:&#x2F;&#x2F;masse.app</a> has it&#x27;s entire backend running on F# + .NET Core + AWS (Lambda and Fargate). Works great!
Solar19over 6 years ago
I&#x27;ve wanted to learn F#. I&#x27;m particularly curious about parsing and text processing, and wonder whether the pattern matching feature would work well for that.<p>It would be great to see an HTML minifier in F#. I&#x27;ve thought about building one as a way of learning the language. An F# based static site generator, similar to Jekyll or Hugo, would also be neat.<p>Compilation of F# is a confusing story to me. If it&#x27;s still compiling to an IR, and getting JITted at runtime, that seems kind of inefficient in a world where Go exists. There&#x27;s the CoreRT project, I think, that allows for precompiled .NET applications, but I&#x27;m not sure how F# fits in. I also read that all Windows Store&#x2F;UWP applications are precompiled on Microsoft&#x27;s cloud. I&#x27;m curious about compile-time flags and optimizations for F#, but they&#x27;re rarely mentioned.
评论 #18669582 未加载
评论 #18669561 未加载
评论 #18669554 未加载
insulanianover 6 years ago
My favourite F# features:<p>- Single-case discriminated unions. I feel so unprotected when working in C# due to IDs usually being primitive types. You&#x27;re never sure if you&#x27;ll accidentally flip two `int` parameters in a method call.<p>- Automatic currying and partial application in combination with piping `|&gt;`. Enables so intuitive and elegant code flow.<p>Performance characteristics are decent as well[1].<p>[1] <a href="https:&#x2F;&#x2F;benchmarksgame-team.pages.debian.net&#x2F;benchmarksgame&#x2F;faster&#x2F;fsharp.html" rel="nofollow">https:&#x2F;&#x2F;benchmarksgame-team.pages.debian.net&#x2F;benchmarksgame&#x2F;...</a>
galkkover 6 years ago
I love F#, but it seems like the language is either abandoned or on life support by Microsoft - compare the feature development speed of C# and Typescript against F# and you&#x27;ll see that.
评论 #18670769 未加载
评论 #18669902 未加载
评论 #18670067 未加载
keithnzover 6 years ago
I played around a lot with F#, and I really like it, but I got to this question of why use F#, and it is actually really hard to come up with a good answer to it, mainly because C# is really good and the real question in .NET is why use F# over C#. If you program with the same mindset of F# in C# then the differences are not super quantifiable.<p>In general terms F# as a language is nicer than C#, but my real question is it good enough that you&#x27;d want to covert to it if you are mainly a group of C# programmers, and I reached the conclusion that it&#x27;s probablly not simply becaus C#, in general, is not really that horrible to start with and a lot more people do things in C# and everything in the .NET world is looked at through the lens of C#. I asked a similar question on the F# communities slack, and beyond a few language features ( that are nice! comprehensions and discriminated unions, and more concise syntax with implicit typing ) it&#x27;s really hard to find a reason. Part of the problem is there is very little in terms of libraries that are unique for F# that massively jump start you in any particular direction. What&#x27;s more, quite a lot of F# code that fits in with frameworks that were built in C# often just look like C# written in F#. F# code written with F# oriented libraries are really nice and super concise, but it&#x27;s a bit of a lonely world.
评论 #18669389 未加载
评论 #18669463 未加载
评论 #18669424 未加载
dkrikunover 6 years ago
Seems like a decent alternative to C# on dotnet. Its a pity it feels second-class.
Koshkinover 6 years ago
The curly brackets is not “coding noise.”
评论 #18670407 未加载
评论 #18669406 未加载
评论 #18669693 未加载
评论 #18669722 未加载
ainar-gover 6 years ago
They show the “type-safe printf” example there, but they don&#x27;t seem to explain anywhere, if I can write my own type-safe variadic function or not. Is printf a built-in that is built with magic not allowed for mere mortals or do they just not dive into the topic because it&#x27;s complex? Can any F# affectionados elaborate?<p>Also, they only talk about units of measurement in the context of floats. Can I not have integers or rationals with units?
pjmlpover 6 years ago
Lack of support in all targets that require .NET Native, no love from the teams that do .NET graphical tooling, a couple of high figures on the community that love to bash C# and VB.NET and the company that makes it possible that F# exists to start with, is what puts me off to invest more time into F#.<p>It is one of the best ML derived languages, but as it is, I rather wait for C# and VB.NET to keep getting features from F#.
评论 #18670260 未加载
staticassertionover 6 years ago
If I want to learn F# is there a good IRC&#x2F;slack channel I can get on? I&#x27;d like recommendations for libraries. I have a project I could throw at it for fun&#x2F; learning.<p>P.S.<p>Can someone explain this?<p><pre><code> &#x2F;&#x2F; complex types in a few type Employee = | Worker of Person | Manager of Employee list</code></pre>
评论 #18675447 未加载
评论 #18669892 未加载
评论 #18669884 未加载
评论 #18669953 未加载
month13over 6 years ago
Wow, and I was just looking at mixing this in with a API C# dotnet core app I was playing with.<p>Wish it was easier to mix the two, it&#x27;s pretty nice being able directly interface through dotnet, be even better if I could have fs and cs files next to each other.
评论 #18671031 未加载
hexoover 6 years ago
and yet they impose nonsensical CamelCase on us where unsuitable as always, for example - this.IsEven... i&#x27;d say IsEven is a type, buuuuuuuuuuuuuuuuut, how can I know here in F#?
评论 #18671620 未加载
verinusover 6 years ago
imho one of the best sites for learning a programming language if you already know how to program.<p>My biggest problem with F# is the bad tooling. For professional coding you need tools like static analysis, refactoring and so on.<p>with those you can use the knowledge of other to improve your code.<p>R# did a lot for C# in that regard.
rusabdover 6 years ago
Does anyone know specific teams in Microsoft which are mostly F#? I might start to target them :)
Paraestheticover 6 years ago
I like f# because most of the notes in the scale are black keys, so don&#x27;t have to move my hands very much to play the whole scale... Of course I know what you&#x27;re talking about.
Jenzover 6 years ago
I&#x27;m impressed :o
gambitingover 6 years ago
&quot;F# is not cluttered up with coding “noise” such as curly brackets, semicolons and so on.<p>You almost never have to specify the type of an object, thanks to a powerful type inference system.&quot;<p>As a C++ programmer, both of those sentences make me shudder. Lack of specified types reduces readability by an order of magnitude, at least for me personally, and especially with complex projects I end up spending a lot of time trying to guess &quot;what is the compiler going to assume this object is&quot;(looking at you, &quot;auto&quot; nonsense in C++)
评论 #18670765 未加载
评论 #18670903 未加载
评论 #18671817 未加载