I got the concept of immutability, but I inevitably ended up recreating OOP patterns whenever I tried working with F#. I do Asp.net WebAPI Projects and trying to do dependency injection ends up just translating C# to F# code rather writing idiomatic F#. I just don't know if HTTP is something F# is really good at doing. I can see it being really useful if you were writing something math-heavy
Any particular documents/tutorials you recommend? Feels like SAFE doesn't have a ton of either but I might just be looking in the wrong places. Like I admit I didn't try the Dojo yet because that sounded like a second round of learning not the very basics, but I'm also only eh at web development
Appreciate the links. Fable/SAFE has been something I'm curious about for a while. And I already meant to look at the elmish book but had not gotten around to it.
I've actually gone through most of the Dojo tonight except for the reset button.
I tried using the safe stack, but it seemed like it wasn't up to date with the latest version of .NET. Is that normal? Or did I hit a weird edge case in the ecosystem? (Or was it a case of PEBKAC?)
Yes you're right that they are a little behind. Currently on .Net 6. That is a shame as .Net 7 seems to have made significant improvements to performance.
That said I don't think there are any features that I'm missing out on being at .Net 6.
I think there is a limited number of maintainers of the SAFE template so they might not be able to keep on the bleeding edge. But it's not that hard to update the components to the latest versions. As can be seen on this waiting pull request https://github.com/SAFE-Stack/SAFE-template/pull/564
I should also mention that when I've hit issues with packages not working on the latest .Net version I've asked in the F# slack and twice had the maintainers fix things within a day so it would run at the latest version.
I found the Slack channel to be pretty responsive and friendly. Still, I was a bit bummed because I kept running into issues. Some documentation links were broken and I tried to fix them, but I couldn't get the project to build on Debian. I tried safe stack and had the wrong version of .NET. Once I got the right one, I had issues running the project (turned out the path did not support the "#" character). A lot of the documentation assumed you knew the .NET ecosystem, but I was coming from python. It seemed like I kept hitting sharp edges.
I'm still curious about F#. It has a lot of neat looking features (units of measure, computation expressions, active patterns) and has some of the easiest to read code I've seen. I just don't know if my experience was representative or if it was abnormal. :/
Yeah the .NET learning curve is steep. It's a little worse than some other languages out there. I found the same thing. I came from a Linux background, PHP, Perl and similar.
ah. yeah, if you are doing web programming. then for F#, you would use a library that is really like a DSL for the web. One of the things in practice in F#, it seems the most useful libraries are written as DSL's, so it is like a language extension for doing 'whatever'. To really get these web based ones, need to understand "ELM architecture".
In any case. I get it. If you have done ASP.NET, and C#, then suddenly this F# way of building web pages by programming through combining functions, it is hard to get over the hump. Like brain has to re-change how to think through the whole flow.
Really, F# on the web is like ELM.
Giraffe is nice because it is itself built "just" as ASP.NET Core Middleware so it plays a bit more nicely than Suave with a mixed stack of C#-defined Middleware.
It's more likely you accidentally fall back into just translating C# patterns to non-idiomatic F# with Giraffe, but it's also nicer when in that case of needing to live in both worlds and use a mixture of libraries built for C# ASP.NET projects.
F# is severely hampered by its standard library, which is object-oriented by design. Some newer things like fluent api's or object initializers are more amenable to F#'s functional style, but on the whole my experience matches yours: as soon as you start interfacing with any .net library, it feels like you're writing in a foreign language.