There are many language features and aspects of the F# language that make it easy to be productive when writing code:
Succinct: You write less code with F# that's also expressed in a clear manner.
Performant: F# comes with built-in parallelism and concurrency. It also uses the fact that it's part of the .NET runtime to speed things up.
Robust: There are language constructs that makes the code fault tolerant and robust like immutable by default, null value management and more.
Supports multiple programming paradigms: F# lets you choose the patterns and practices most effective for solving problems by providing strong support for functional and object programming paradigms.
How do I get started?
There are a few things you need to get started.
.NET SDK. You need to install the .NET SDK to be able to buiild, run, test and also create F# projects. You can find theF# SDK installhere
Ionide. It's a VS Code plugin. It's not necessary to install, but it will give you things like Intellisense, tooltips, codelens, error highlight and more.
Your first code
You can start writing F# by using the REPL called FSI, you can also scaffold an F# project using thedotnetexecutable.
Create a project
You create a project usingdotnetlike so:
dotnet new console --language F# -o MyFSharpApp
Then you get a project with files:
Program.fs, your entrypoint file
MyFSharpApp.csproj, your project file that contains everything it needs to know to build the project like dependencies for example.
What does the code look like?
Here you have the code ofProgram.fs. Itt contains the functionsfrom()andmain().main()is the entry point of the app, as seen by[<EntryPoint>].
// Define a function to construct a message to print
let from whom =
sprintf "from %s" whom
let main argv =
let message = from "F#" // Call the function
printfn "Hello world %s" message
0 // return an integer exit code
Thefrom()function takes the argwhomand the function body prints a string using the functionsprintf.