I’m pretty new to F# and Functional Programming, at least from a production perspective.
I’m studying Domain Modeling Made Functional by Scott Wlaschin.
Since I have to put in production a REST API and a Webapp and I want to do it in F# following those principles, which do you think can be the simplest framework for implementing it from a practical perspective?
I thinked of SAFE Stack (actually my first choice), Suave, Websharper or Simple ASP.NET Core…but I have no suffice experience to choice the best solution
I’d suggest WebSharper. I’ve been working with it for over 3 years in a fairly large code base now, and it is really good.
WebSharper is now at version 4.0
You can start with ASP.NET Core and then depending on your level of F# expertise with F# you can either use classes as usual to get a feel for F# or if you are already at that level you can go straight to Giraffe for the functional approach you want to take.
I think this is superiour to Suave, for example, as you can use a lot more community knowledge and official ASP.NET Core documentation is superb.
Note that even if you use classes in F# you can still benefit from domain modelling as in the book with F# type system. I.e. not everything needs to be functional as with Giraffe/Suave. You’ll still be able to enjoy a lot of the benefits of F#.
I would have a play with Giraffe and Saturn and decide what you like.
Giraffe stays close to the ASP.NET APIs whereas Saturn introduces some nice computation expressions over the top of it.
Personally as a beginner I struggled to know how to override Saturn when I needed to, and it’s at version 0.9. Despite it aiming at simplicity (and it’s heading in the right direction here), I feel I’d need to be a bit more advanced before I can get on with it. In my view Giraffe is definitely production ready though, and I’d have no problem basing a projection on this as the foundation - documentation is decent.
You’ve already found the SAFE stack. If I was doing a personal project I’d start there. For a team project I’d start with a raw Giraffe template - there’s a command line switch to create the template without a UI. I felt the latter approach gave me the best understanding of what was going on under the hood.
Disclaimer: I’ve never put an app into production.
Here’s a twitter thread discussing this topic: