News for hackers. Stuff that matters.
Re:Why F#? by GiorgioG on Tuesday April 01, 2025 @11:35AM (#43548051)
As a 20+ year C# dev...where do I learn how to structure apps in F#? In C# my ASP.NET Controller might use a service (or a mediator) to execute some domain logic and that in turn will use a repository pattern (or EF DbContext) to update/query a database. How are dependencies injected in? It seems like there are multiple ways of going about it, but I don't have enough knowledge of F# to know 'the proper way' to do it.
Re:Why F#? by JohnyTex on Tuesday April 01, 2025 @12:05PM (#43548427)
The situation is a bit more complex in F# than C#, as there are multiple ways to do it. Scott Wlaschin has a good overview post about it here:

https://fsharpforfunandprofit.com/posts/dependencies/

FWIW you can do it exactly the same way you do it in C#; it’s not “wrong”, it might just feel a bit out of place.

Re:Why F#? by Lanayx on Tuesday April 01, 2025 @09:40PM (#43552968)
Re:Why F#? by aaronmu on Wednesday April 02, 2025 @05:15PM (#43561705)
Just start. Use whatever style you are used to. Use controllers. Adapt your style as F# pulls you deeper inside the pit of success. You'll struggle the first couple of features, but you'll reach a sweet spot between your current style and functions relatively fast.
Re:Why F#? by GiorgioG on Thursday April 03, 2025 @07:52AM (#43568294)
I suspect you're right. I just have to get over the hump of being uncomfortable/fumbling my way through things that I would otherwise know how to do in C#. Thanks!
Re:Why F#? by tubthumper8 on Friday April 04, 2025 @11:08AM (#43583546)
"pit of success" from the previous comment might refer to this video, which is long but good especially to adjust to a different mindset

https://youtu.be/US8QG9I1XW0?si=N07ZsYSYfA12mGVc