coonsta coonsta

Niner since 2006

Dominic is a software design engineer in sunny Redmond, WA.


  • Don Syme: Introduction to F#, Part 2

    Hi Andy,

    Most of the unusual syntax (open, let, <-, =, etc.) comes from Ocaml. The intersection of Ocaml and F# is large enough that you can write significant programs using only that subset and compile them as MSIL, Ocaml byte code, and Ocaml native code. In fact, this is how the F# compiler was bootstrapped: The F# compiler started life as an Ocaml program.

    As language features are added to F# they tend to be very .NET-oriented, so the full F# language is definitely a new .NET language and not just an Ocaml variant.

    F# syntax is fairly different from C#, and that can be overwhelming initially. To get a good feel for the language, why not look at the F# samples and try to write some toy programs? When you see something that feels foreign you're probably looking at an F# idiom that doesn't exist in C#. Sometimes in those seemingly dark corners lie the really cool differences between C# and F#.

    Once you have some familiarity with the F# and aren't just stumbling over syntax, try writing some bigger examples. Maybe write something in C#, then in F#; then try another problem first in F# and then in C#. This is a good way to appreciate the difference between C# and F#. I'm pretty sure you'll get a feel for how "thinking in F#" can improve the design of your C# programs.

    For example, in C#, when you have classes with virtual methods spread over various files, the F# programmer may think of discriminated unions and pattern matching (think of a virtual method call like a pattern match on the constructor). Then you appreciate some aspects of F# that are just unbelievably clean and cool. (Want to match on two values? It is very easy with pattern matching in F#. Doing a similar thing in C# is a bit messy and can lead to a bit of a code explosion.)

    I've been noodling around with F# for quite a long time, so your experience as a newcomer to F# is very different than mine--which makes your insights doubly interesting. Please post to this forum; or on the F# community site, hubFS; or send me mail (dominic at dcooney dot com.)


  • Don Syme: Introduction to F#, Part 2

    Chadk wrote:
    What is the language aimed for? Scripting? Or is is supposed to be an anlternative to C#?

    F# is a general-purpose language so there are a lot of programs you would write in either F# or C#. Outside of the mainstream, F# and C# both have some specific niches where they excel: F# is great for writing compilers and mathsy stuff; C# has more of a systems programming feel--munging with pointers, structs and unsafe code.

    In my experience F# is much more succinct than C#. That, with features like Python-style whitespace indentation and type inference, make F# feel much more "scripting" than C# does.
  • Don Syme: Introduction to F#, Part 2

    Ion Todirel wrote:
    why language is named F#, i mean why not just F or other name?

    I think this is a nerdy in-joke; I'm sure Don can correct me if I'm wrong: F#'s theoretical roots are the polymorphic, typed lambda calculus, otherwise known as System F. (Sounds kinda like Plan 9 From Outer Space to me.) Of course, to be .NET hip you have to be something-sharp, hence system F + # = F#.
  • Don Syme: Introduction to F#, Part 1

    It's hard to "get" F# the first time you see it because it is so different from C#. I encourage you to download the  F# compiler, play with the samples, and try to write something with it. Feel free to send questions my way, or to The HubFS-- , or to the F# mailing lists.
  • Don Syme: Introduction to F#, Part 2

    ChadK: Which part is confusing? Let's break it down!

  • Don Syme: Introduction to F#, Part 2

    The DirectX donuts demo is available on The HubFS--the F# community site: