20 ms·
I love seeing F# mentioned on Hacker News, but this article in particular is a bit dubious. Yes, you can use F# from C#, but it gets frustrating quickly. Fortu
by munchler 3y ago
I love seeing F# mentioned on Hacker News, but this article in particular is a bit dubious. Yes, you can use F# from C#, but it gets frustrating quickly.
Fortunately, almost anything you can do in C# can be done better in F# anyway, so there's really very little need to use C# at all once you take the plunge into functional programming.
- gsuuon 3y agoI agree - I guess this article is more about a (very) gradual way to adopt F# into an existing C# code base, rather than an inherently useful combination of C# and F#.
- munchler 3y agoTrue, but for any serious integration the F# library should expose an API that's designed to be more idiomatic for C# callers. When I see `ListModule.OfSeq` being called from C#, I cringe a little.
- ClimaxGravely 3y agoWould you mind sharing some of the frustrations you have had using F# from C#? I haven't hit anything too hard yet but I also haven't worked on any large projects that are setup like that. In regards to the C# vs F# issues. Have you tried using WPF or any desktop GUI frameworks from F#? If so how was the experience?
- munchler 3y agoHere's a quick example of the kind of trouble you can easily get into when calling idiomatic F# from C#: https://stackoverflow.com/questions/1952114/call-a-higher-order-f-function-from-c-sharp https://stackoverflow.com/questions/1952114/call-a-higher-or... It's been a few years, but yes, I've implemented WPF apps in F# and found it quite doable. FsXaml was very helpful: https://fsprojects.github.io/FsXaml/ https://fsprojects.github.io/FsXaml/
- ClimaxGravely 3y agoThanks for the information! I figured I hadn't really scratched the surface on this stuff. I'm quite interested in making a GUI from a functional language. This could be a good way to kick the tires.
- oaiey 3y agoReactive Programming I guess is the key to GUIs from F#/FP perspective. It is the modern way of doing things anyway but requires then a UI stack which is optimized for it.
- ClimaxGravely 3y agoAh funnily enough I did use that a fair amount in my C#/WPF days. Rx does indeed seem like a good fit.
- sinuhe69 3y agoC# is required for the UI programming, though. I don’t know any F# module, which interacts and manipulates UI elements. Yes, creating a web UI is possible, but not for the desktop. I’d love if someone could point the way around (because until today, I’ve to combine both languages for desktop appt)
- Smaug123 3y agoAvalonia does Just Work from F#; it even has `dotnet new` templates for F# (https://github.com/AvaloniaUI/avalonia-dotnet-templates https://github.com/AvaloniaUI/avalonia-dotnet-templates).
- sparkie 3y agoAlso check out Avalonia.FuncUI: https://github.com/fsprojects/Avalonia.FuncUI https://github.com/fsprojects/Avalonia.FuncUI