Throughout this week, we've published a series of articles contributed by some well-known people within the F# community focused on web and cloud programming. Today, we're announcing the launch of the SAFE stack initiative, which brings all of the elements together as a cohesive story:
- Saturn model for server-side web programming
- Azure for cloud-based systems
- Elmish for an easy-to-understand UI programming model
In collaboration with our partners, we've today launched the SAFE website, which we are hoping becomes the go-to place for people developing functional-first, cloud-ready web applications.
What is SAFE
It's important to understand that SAFE in itself is not a stack that forces you down the route of using the specific technologies named above. Instead, think of them as a starting place to refer to when you're considering an end-to-end solution in F#; we suggest that the key behaviours in SAFE web technologies should include:
- Embraces functional programming paradigms
- Excellent support for F#
- Readily deployable to a cloud provider
- Adheres to common standards where possible
Here's a little more detail on this philosophy for each component in the stack.
The Saturn Model
It's key to understand that whilst we are fans of Saturn, we believe that there's also room here for other F#-friendly web programming models. As mentioned in the web programming article of this series, this also includes "dropping down" to Giraffe, Freya and WebSharper.
Whilst we at Compositional IT are big fans of Azure and recommend it as our default cloud provider for customer solutions that require scalable, flexible and easy-to-use services, we know that not everyone feels this way. As such, there's no reason with the SAFE stack can't work equally well on Amazon Web Services (AWS) or Google Cloud Platform (GCP).
Elmish provides an excellent option for a UI model that supports some of the core principles of functional programming, such as immutability and expression-based programming, whilst taking full advantage of many of F#'s language features such as discriminated unions and pattern matching. There are other UI models available such as (again) WebSharper's Piglets and Formlets models etc., that you
SAFE isn't an "all-or-nothing" choice
SAFE isn't a prescriptive solution that forces you to go "all in" either. Here are some alternative application architectures that utilise a variety of elements of the SAFE stack in different ways.
Prototypical SAFE stack
Here's a typical SAFE stack using all the "default" technology set.
An example of this is available on the SAFE github repository with the SAFE Bookstore app.
Alternative SAFE stack
Here's an alternative version of the SAFE stack that uses some other technologies for the same purposes as the original stack, such as AWS for hosting, and Giraffe for the server-side web stack - this is also totally cool.
Partial SAFE stack
Here's a partial implementation of the SAFE stack, which uses F# for the server side, but uses conventional a Typescript + AngularJS combination for the client side.
On-Premise partial SAFE stack
This is another partial implementation of the SAFE stack, this time using an on-premise installation of the stack, possibly using IIS for hosting the web application, whilst using on-premise database and messaging systems.
By adding React Native into the mix, there's nothing to stop you creating mobile applications using the SAFE stack. There's an example of this with the SAFE Nightwatch sample, too!
It's early days for SAFE, but we feel that this is a particuarly sweet spot within the F# world. We're hopeful that the F# community will come together to collaborate and make the SAFE site the go-to place for someone looking to get up and running with these sorts of applications.
Please do bookmark the official website - we'll be making lots of updates to it in the coming weeks, including adding more documentation and reference applications using alternative stacks. We're also considering doing the following:
- Creating NuGet metapackages that contain references to all these packages to get you up and running quickly
- Creating ready-made paket.dependencies + lock files which you can use to get started
- Simple .NET Core templates for "ready-to-go" solutions, whilst being mindful of avoiding code-bloat that can adversely affect ready-made solutions.
Please, also follow the official safe_stack Twitter account as well for the latest news over the coming weeks. We'd love to hear your feedback - please reach out to us.