11

Possible Duplicate:
In what areas might the use of F# be more appropriate than C#?

I'm anticipating giving a presentation at the local .Net user group about F#. And I'm anticipating the "Why should I look into F#?" question from the audience. I know most of the stuff that can be done in F# can be done in C# too--so I'm looking for things that can be done easily in F# that are really hard to do in C# (e. g. pattern matching). And if there are already good answers to this question, please just link them in comments and I'll close this up. I did see a few things but if there's already a question that addresses this I didn't find it.

By the way, if any of the moderators want to mark this community wiki please feel free; this seems more like a survey question to me anyway.

Community
  • 1
  • 1
Onorio Catenacci
  • 14,928
  • 14
  • 81
  • 132
  • 1
    I'm tempted to vote to close this because it sounds subjective and/or argumentative. But I'm not 100% sure about that. – Bobby Apr 28 '11 at 13:44
  • @Bobby, as I say, if someone wants to mark this community wiki that's fine with me. I realize this is sort of a survey question but I can't mark the question community wiki myself. – Onorio Catenacci Apr 28 '11 at 13:45
  • 1
    (just a side note: a lot of times I've seen this question compare good F# to bad C#, i.e. Not using appropriate C# devices; I'm not saying there aren't differences - but be aware of that gotcha; note also how C# 5 (the async CTP) improves the threading powers of C# with continuations etc) – Marc Gravell Apr 28 '11 at 13:48
  • @Bobby, I'm still relatively new to stackoverflow, and appreciate the goal of avoiding questions that get transformed into jihads. I think this question solicits opinions that don't require argument. I look forward to seeing the answers to this. Is there another another forum that is more appropriate for a question like this? – Cos Callis Apr 28 '11 at 13:49
  • @delnan--Thanks for the links. My google fu must be failing me. I'll close this question since I believe it is a dupe. (Edit): Hmm...thought as the person who posed the question I'd be able to automatically close it. Guess I was wrong. – Onorio Catenacci Apr 28 '11 at 13:52
  • @Cos Callis: Not on SE as far as I can see. This is a Q&A network and all sites are trying to avoid possible subjective and argumentative questions or the kind which can be turned into a discussion. But most of the time the wording makes a big difference, as in this example. – Bobby Apr 28 '11 at 14:00
  • 3
    Voting to reopen. I'd answer the alleged duplicate question with generic application domains (e.g. "heavily concurrent server applications" or "programmatically-generated GUIs") whereas I'd answer this with specific code samples (e.g. some mutually recursive asynchronous workflows implementing a state machine in an elegant way that relies upon tail call elimination, or a parser written as a set of mutually-recursive active patterns, or a simple concurrent program doing message passing using a `MailboxProcessor`). – J D Apr 28 '11 at 14:59
  • 4
    IMMUTABILITY! It's a huge pain in C#. Here's a simple--yet painful--example: http://stackoverflow.com/questions/5172510/should-i-choose-f-to-develop-a-distributed-server-platform/5172903#5172903 – Daniel Apr 28 '11 at 15:53
  • 1
    I think there are plenty of questions that already cover this topic. Just look at the list of the highly voted F# questions: http://stackoverflow.com/questions/tagged/f%23?sort=votes&pagesize=50 – Tomas Petricek Apr 28 '11 at 16:40
  • @Tomas: I don't think that is a constructive response. In particular, I don't see any questions with answers like the ones I described above. You might as well just tell the questioner to master F# himself using all available information and then answer his own question... – J D May 01 '11 at 12:16

3 Answers3

5

Since F# is a functional language, it should be far easier to implement a domain-specific language in it.

T.E.D.
  • 44,016
  • 10
  • 73
  • 134
4

One of a main concept is asyncrounus calls in F#, also F# uses immutable variables so concurrency is easy.

see http://research.microsoft.com/apps/pubs/default.aspx?id=147194 and http://research.microsoft.com/apps/pubs/default.aspx?id=79947 and other Don Syme articles. may be there are other differences, but I think gathering them here is just doing your homework.

Saeed Amiri
  • 22,252
  • 5
  • 45
  • 83
  • 1
    In particular, the *Async* functionalities in F# are production-level quality, while the Asnyc functionalities of C# (and VB.NET) are still in CTP phase. – Heinzi Apr 28 '11 at 13:49
  • 1
    And tail call elimination makes async far more elegant in F# anyway. – J D Apr 28 '11 at 14:55
2

i would say

  • Asynchronous programming.
  • Units of measure
Maged Samaan
  • 1,742
  • 2
  • 19
  • 39
  • 2
    Units of Measure is nice, but it is a hack much like Java generics (erasure), meaning no reflection, no use outside of the assembly. – Robert Jeppesen Apr 29 '11 at 22:01