Introduction
Key points
Microsoft language family on the .NET platform
Designer: Don Syme @ Microsoft Research
β OCaml implementation for .NET
β Inspired by Haskell (Version 1.0 in 1990)
dotnet new -lang Fβ―
Interoperability between Cβ― and Fβ― projects/assemblies
Multi-paradigm language Functional-first and very concise
Whereas Cβ― is imperative/objective-oriented-first and rather verbose (even if it's inspired by Fβ― to become more succinct and functional)
History
2002
Cβ― 1.0
.NET Framework 1.0
VS .NET 2002
2005
Cβ― 2.0
Fβ― 1.x
.NET Framework ?.?
VS 2005
2007
Cβ― 3.0
.NET Framework 3.5
VS 2008
2010
Cβ― 4.0
Fβ― 2.0
.NET Framework 4
VS 2010
...
...
...
...
...
2019
Cβ― 8.0
Fβ― 4.7
.NET Core 3.x
VS 2019
2020
Cβ― 9.0
Fβ― 5.0
.NET 5.0
VS 2019
...
...
...
...
...
2024
Cβ― 13.0
Fβ― 9.0
.NET 9.0
VS 2022
Editors / IDE
Visual Studio / Rider β β Less refactoring capabilities than for Cβ―
Fβ― interactive (FSI)
REPL available in VS, Rider, vscode +
dotnet fsi
Usage : instantly test a snippet
π‘ In the FSI console, enter
;;
at the end of an expression to evaluate it
Example from vscode with ionide:
π‘ In the FSI console, enter ;;
at the end of an expression to evaluate it
βοΈ Notes:
Cβ― interactive is more recent (VS 2015 Update 1). The FSI was there from the get go.
File types
4 file types: .fs
, .fsi
, .fsx
, .fsproj
β οΈ Single language : for Fβ― only
Standalone file
Script file
.fsx
Executable (hence the final x) using the FSI
Independent but can reference other files, DLLs, NuGet packages
Project files
In Cβ― :
.sln
contains.csproj
projects that contains.cs
filesIn Fβ― :
.sln
contains.fsproj
projects that contains.fs(i)
code files
π‘ Easy Interop = Combine both .csproj
and .fsproj
projects in the same .sln
.fsi
are signature files (i for interface)
Associated with a
.fs
file of the same nameOptional and rather rare in codebases
Usages
Reinforces encapsulation (like
.h
in C)Separate long documentation (xml-doc)
Fβ― Project
Creation in the IDE or using the CLI dotnet
:
dotnet new -l
: list supported project typesdotnet new console --language Fβ― -o MyFSharpApp
CrΓ©ation of a console project named
MyFSharpApp
--language Fβ―
is key to specify the language, by default in C#
dotnet build
: to build the projectdotnet run
: to build the project and run the underlying executable
Last updated
Was this helpful?