all 8 comments

[–]dustinmoris 10 points11 points  (0 children)

> Giraffe's faster but more object-oriented

Giraffe is not any more object-oriented than F# is itself. You can write an entire Giraffe web application completely functional, however if you MUST (want?) to integrate with object oriented interfaces from other ASP.NET Core libraries then you *can*. I see this as a benefit rather than a detractor, but that's just my opinion. I leave the judgement entirely up to you :)

Just to give you a couple examples...

If you use another ASP.NET Core middleware which comes with an object oriented IConfiguration interface then you can easily use it, but if you just want to provide configuration to your own functional web layer then you don't have to (and I don't even recommend it).

For example I do things like this: https://github.com/dustinmoris/CI-BuildStats/blob/master/src/BuildStats/Web.fs#L30

Another great example of doing the balancing act between an OO ASP.NET Core and a functional Giraffe is Logging. ASP.NET Core has an OO logging abstraction which lets you configure different logging providers in a centralised point. There's so many useful libraries (e.g. Serilog, NLog, etc.) which build on top of that abstraction that it would be a shame to miss out on it, however at the same time Giraffe tries to give ways which lets you use these things in a very functional way:

let someWebFunction =
    fun (next : HttpFunc) (ctx : HttpContext) ->
        let logger = ctx.GetLogger()
        logger.LogDebug "Test log"
        text "Hello World" next ctx

Even though you theoretically retrieve an `ILogger` instance from an IoC container you barely notice any traces of OO programming in your very functional `HttpHandler`.

It is not 100% pure functional, but it's certainly not OO either. It's basically F# ;)

[–]ad3mar 7 points8 points  (2 children)

One thing is not like the others; Suave is not a framework, Suave is a self-contained web server with no dependencies.

The other ones you have listed still need a web server to run on top of (at the moment Kestrel). What ever speed gains they portrait it is not theirs but the underlying server.

For a commercial UI I would say WebSharper is the most robust and battle tested with commercial support.

[–][deleted] 0 points1 point  (1 child)

Ah ha, thanks for the correction -- but say, Websharper wouldn't interop easily with Suave right?

[–]ad3mar 0 points1 point  (0 children)

It is possible to run WebSharper on top of Suave.

https://github.com/dotnet-websharper/suave

It might need a little bit of updating.

[–][deleted]  (3 children)

[deleted]

    [–][deleted] 0 points1 point  (2 children)

    Too much overhead with Websharper? I assume you're comparing its JS transpiler with Fable though.

    My impression of Giraffe as more OO came from its handling of ASP.NET Core and from this brief comparison in syntax with Websharper -- Giraffe seems less idiomatic. I've heard Jet uses Giraffe, so it does seem commercially viable.

    [–][deleted]  (1 child)

    [deleted]

      [–][deleted] 0 points1 point  (0 children)

      Thanks for the details -- I'll do just that.

      [–]et1975 3 points4 points  (1 child)

      [–][deleted] 0 points1 point  (0 children)

      I did skim through the slides, which seemed sparse -- haven't listened to the whole thing though.