Basics 01 - The Ceremonial Hello World

Here it comes, the Hello World for F#:

Learning-FSharp/Ch01-HelloWorld/Program.fs

Check out all the comments that are placed in the source file.

Key Ideas

  1. Multi-line comments: (* comments *)

  2. Single-line comments: // comments

  3. The program entry point: let main args =

  4. The entry point should be decorated with: [<EntryPoint>]

  5. Pamaters that are passed to a function are separate by space, not a comma

  6. There are no opening/closing brackets for the function body; no semi-colons for line ending

  7. The function body should be indented

  8. The return value of a function is the last expression in the function body

  9. .NET library is accessible from F#

Compilation Order in F

  1. Unlike C#, compilation order in F# is important

  2. This means:

    1. The order in which files are compiled

    2. The order in which content within a file is present

  3. Simply put, if A refers to B, B should be compiled before A

  4. To change the order of files, edit the .fsproj file

  5. Within a file, place namespaces, modules, types and functions accordingly

  6. If within a file there is circular dependence, use rec (recurring, more on this later)

  7. The main function, the entry point should be the last declaration in the last file

If you have reached so far, congratulations.

Keep reading!