20

These days I am interested in learning F#, and would like to use it for GUI applications. Unfortunately I have no previous background in .Net or C#. Are there any good resources (web sites, books) for learning this without going through C# first?

Many thanks in advance.

Muhammad Alkarouri
  • 23,884
  • 19
  • 66
  • 101
  • 1
    This is a bit like saying how can I learn to paint with a pencil ;) – Benjol May 11 '10 at 08:23
  • 4
    @Benjol: Why? I can understand that you believe that GUI programming should be in an IDE like VB, C#, Java, Delphi, etc. I don't think that is the only way, and the answers do give good options. May be the better idea is to combine F# with C# as in one of the links, but may be then functional reactive programming is not so bad. What's your opinion? – Muhammad Alkarouri May 11 '10 at 13:29

5 Answers5

20

The Real-world Functional Programming book that I wrote with Jon Skeet (sorry for the advertisement!) expects some existing knowledge of object-oriented languages (e.g. C#) but it briefly explains all more advanced features that C# has compared to, for example, Java.

It has a few examples of GUI programming using WinForms (a more modern framework would be WPF, but some concepts are essentially the same). You can take a look at a few examples, because there is some free content related to GUI:

  • Chapter 4 (coincidentally, available as a free sample :-)) shows how to implement an application for drawing simple graphs using basic features.
  • Programming user interfaces using workflows (free excerpt) shows one advanced pattern that's very useful for writing reactive applications (as I know, this isn't described anywhere else in much details)

As far as I know, Robert Pickering's Beginning F# also has some user interface examples and it also includes some WPF examples (although I don't have the book yet, so I don't know what exactly does it contain).

However, none of the F# books will make you GUI Expert. You'll still need to spend some time learning about WinForms/Silverlight/WPF in more details. There are plenty of examples in C# on the internet and after reading one of the above, you should be able to translate them directly to F#, but buying a technology-specific book may be a good idea too.

Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
Tomas Petricek
  • 240,744
  • 19
  • 378
  • 553
  • Can you use winform/WPF designer in visual studio with F#? – BlueRaja - Danny Pflughoeft May 09 '10 at 01:49
  • 1
    @BlueRaja: Not directly, but you can create a C# project just to contain the designer-generated code. See this post: http://stackoverflow.com/questions/2604589/seeing-c-windows-forms-project-code-from-f/2604735#2604735 – Tomas Petricek May 09 '10 at 02:09
  • 1
    I've got your book Tomas and I'd say it's a great place to start. – Onorio Catenacci May 09 '10 at 02:40
  • I've got it too and I what I've read so far is very good. :) – Mark Simpson May 09 '10 at 03:10
  • Thanks for the advice. Looks like a very good book, and with the other votes I am going to buy it. One thing though, does it need actual experience in C#? The description says so. I don't have that, though I have experience in object oriented programming (Java, C++, Delphi). – Muhammad Alkarouri May 09 '10 at 20:11
  • @Muhammad: I think that experience with Java should be good enough. The book expects that readers use the object-oriented mindset. It uses some specific C# features such as iterators or lambda expressions, but all of these are briefly explained in a side-bar (and if you needed to clarify some details, there is a plenty of C# resources on the internet). – Tomas Petricek May 11 '10 at 01:36
  • @Tomas: Many thanks. Iterators and lambda expressions are certainly to be expected in functional programming. I have used them in other languages, and I am sure the side-bar explanations would be enough for the syntax. I have ordered the book. – Muhammad Alkarouri May 11 '10 at 13:33
  • This is a terrible plug. The chapter advertized does not detail gui programming at all. Rather, it gives a single, trivial example of reading data from a file, and drawing a pie chart based on it (with the preexisting FillPie function). It does not go into any detail regarding the Winforms apis, and does not even explain the idioms and structure of the provided Winforms example. In other words, for this to be useful, the reader needs to be familiar with WinForms beforehand. For shame sirs, for shame. – Bladt Oct 20 '16 at 14:33
5

I just got the The Real-world Functional Programming book and if you want to mix F# with GUI stuff that's the book for you since it has plenty of examples and it jumps right into it. That's the main reason I got it :) Online I've come across this and I like the F#/DirectX example. F#.NET tutorials and examples

daveangel
  • 573
  • 2
  • 6
5

My book Visual F# 2010 for Technical Computing has a chapter devoted to graphics using WPF and covers basic WPF controls and the use of WPF from F# interactive. There are also many articles in The F#.NET Journal that cover WPF (scroll down and run some of the downloadable demos). Our F# News often contains short blog posts with WPF-based F# applications in them, e.g. Game of Life in 32 lines of F#.

J D
  • 48,105
  • 13
  • 171
  • 274
2

The Gui designer is okay. But you can create an F# class to contain the same code as it would. Learning how to code forms by hand is very useful. I would personally recommend it over the method of using the C# designer to create the code and then interfacing with it(which would be far more complicated than would be necessary). Besides, all the classes that exist in C# for winforms or WPF programming are exactly the same for F# and are intentionally designed to be used easily in any language using the .net platform.

violet_white
  • 404
  • 2
  • 15
-1

http://searchwindevelopment.techtarget.com/generic/0,295582,sid8_gci1289090,00.html

Requires registration (email address). Don't know if it's any good, but seems worth a look.

MusiGenesis
  • 74,184
  • 40
  • 190
  • 334