Fable is a compiler that lets you use F# to build applications.
Historically, Fable has been used to target JavaScript but since Fable 4, you can also target other languages such as TypeScript, Rust, Python, and more.
typeShape=
| Square of side:double
| Rectangle of width:double* length:double
letgetArea shape =
match shape with
| Square side -> side * side
| Rectangle (width, length)-> width * length
letsquare= Square 2.0
printfn $"The area of the square is {getArea square}"
F# (pronounced f-sharp) is a strongly typed Functional programming language which offers many great features to build robust and maintable code such as:
F# is already used on the server for web and cloud apps, and it's also used quite a lot for data science and machine learning. It's a great general-purpose language, and also a great fit for building beautiful UIs that run in the browser.
Target | Status |
---|---|
JavaScript | Stable |
TypeScript | Stable |
Dart | Beta |
Python | Beta |
Rust | Alpha |
PHP | Experimental |
F# is a great choice to build applications that are robust and maintable code such as.
This is because F# has:
Depending on the target you choose, those benefits will tenfold.
JavaScript is a dynamic language so you don't have a lot of safety when writing code. This can lead to bugs that are hard to find and fix.
With F#, your application will be safer, more robust and more pleasant to read and write. You can refactor your code with confidence as the compiler will tell you if you missed something.
TypeScript is safer then JavaScript but it still lacks some features.
For example, it doesn't really have a way to represent discriminated unions, and so it is easy to miss a case when you are using them. In F#, the compiler will tell you if you missed a case.