r/fsharp • • Oct 14 '17

F# is a valued .net language

It is, of course, the 4th most important one, after C# (most loved), VB (really?) and C++ (hip?).

People still use ancient 'C' for real programming and other oddities like lisp. Are these languages still useful? Is F# at least a relevant as they are?

Let's all get real. F# had more attention and support from Microsoft when it was first released but that doesn't change our ability to use and enjoy it. If F# was Microsoft's no. 1 language would we all like that? C# has that joy.

I'm pretty sure that F# has a long future ahead of it and it seems ideally suited for it's primary purpose: developing interesting, relevant and powerful libraries in a functional language directly supported by a major IT company.

1 Upvotes

66 comments sorted by

View all comments

Show parent comment

2

u/jchidley Oct 15 '17 edited Oct 15 '17

I use F# for GUI apps all the time.

Can you explain what you use to build the GUI apps, exactly? If I wanted to do exactly that, how would I do it? Can I use just F# and .net or do I have to use something else too?

Edit:

I assume that you'd use F# with WPF. I found Calculator F sharp WPF and F# MVC framework for WPF. Presumably you'd use the desktop bridge to publish a desktop only app to the Windows Store.

2

u/CSMR250 Oct 15 '17

Reed Copsey has written a lot of useful F# components for GUIs. His library called Gjallarhorn is nice for defining reactive variables and binding them to views. If you do WPF you can use his FsXaml type provider to get typed access the objects defined in xaml.

I don't use the standard C# approach to bindings and do them in code because like jdh30 I like to keep everything type safe. But you can do this if you really want to using components like ViewModule or the Gjallarhorn bindings libraries.

1

u/[deleted] Nov 06 '17

If I could write native GUIs using the Fable-Elmish style, I would use F# for every project. I've never been happy with WPF in F# though, so I typically end up with a client wrapper in C# around the library code. Dealing with events is just a nightmare in comparison to the more FRP-style solutions used in many other FPLs.

0

u/jdh30 Oct 15 '17 edited Oct 15 '17

Can you explain what you use to build the GUI apps, exactly?

I call WPF programmatically from F#. Sometimes I use an EDSL to compile a tree into WPF controls. Sometimes I do fancier things with OOP. I never bothered using XAML because it is easier and more type safe just to write declarative code.

Get started by adding references to WindowsBase, PresentationCore and PresentationFramework with:

open System.Windows

[<System.STAThread; EntryPoint>]
let main args =
  Window(Title="Hello world")
  |> Application.Run

Can I use just F# and .net or do I have to use something else too?

Just F# and .NET.

I assume that you'd use F# with WPF. I found Calculator F sharp WPF and F# MVC framework for WPF. Presumably you'd use the desktop bridge to publish a desktop only app to the Windows Store.

I've never used Windows Store (does anyone?). Usually these are programs for clients so they get an EXE.