Tips For Beginners
Last changed: -159.182.1.4

.

Tips For Beginners

To use F# effectively you need to learn:

  1. How to use the F# compiler FSC, F# Interactive FSI and/or VisualStudioPlugin
  2. How to write F# functional programs
  3. How to write F# imperative programs
  4. How to use .NET APIs from F#
  5. The details of the specific F# and .NET libraries you would like to use

The F# manual includes a 'Quick Start' section that is a good first step. It also includes the Samples101 sample that gives an interactive way of exploring a number of different programming samples covering basic topics such as arithmetic, tuples, interation, lists and function values.

See also http://research.microsoft.com/fsharp/books.aspx

The F# Handout

A handy beginners guide/reference card to F# was published at http://hamletdarcy.blogspot.com/2008/07/f-handout-available.html. It was released under the Creative Commons license and you are free to use and edit it.

The OReilly OCaml Book

The book can be found at http://caml.inria.fr/oreilly-book/html/index.html

Chapters 2-4 contain the introductory material you are looking for.

The text assumes you are using OCaml, and it might make sense to learn OCaml simultaneously with F#, e.g. to type the programs both into OCaml and F#. F# currently has only an experimental top level interpreter, FSI.exe (read: use FSI.exe at your own risk). The recommendation for F# (at this point) is that you type the programs into Visual Studio or into a text file and compile/run them. If you type them into Visual Studio you can hover your mouse over identifiers you will see the types that have been inferred for your code (the top level interpreters will print out these types).

After that things get a little more language specific:

Chapter 5 is a simple OCaml graphics application. You can do graphics with F# and there are lots of great samples in the distribution, but to use the code from Chapter 5 you would need an F# implementation of OCaml's "Graphics" module. This would actually be a great mini-project, especially if you're already familiar with .NET's System.Windows.Forms.

Chapter 6 contains example applications. They look as if they will work directly, though the first requires the Graphics module.

Chapter 7 is about how to use the OCaml command-line compiler and is not so relevant to F#.

Chapters 8, 9 & 10 (debugging, profiling, libraries, GC), contain lots of interesting material, but only about half is immediately applicable F# - for example, you can profile F# code, but you would use one of the multi-language .NET profiling tools.

Chapter 11 is directly applicable to F#, since lex/yacc generators are supported.

Chapter 12 is about interoperability with C code. For F# you interoperate with C code by either importing COM objects (using the .NET tool tlbimp.exe) or by writing some C# code that accesses the C-functions using the excellent C# constructs built for this purpose.

The C# manual and .NET tutorial material contains all the information you need on these approaches.

Chapter 13 contains further applications, which should be of interest.

The remaining chapters deal with modules, objects, concurrency, communication, distribution and applications. All the material is excellent, and I'd encourage you to look through it, since you'll often find yourself doing the same things in F# and .NET, only slightly differently.