It's interesting to see that a lot of the respondents wrote basically the same thing I did: the documentation for actually making even a simple application in pure F# is basically non-existent.
I literally know of only a single pure F# application tutorial on the internet, Scott W.'s Calculator, and the style reads more like Java than any idiomatic FP code I've ever seen.
There's scattered bits here and there elsewhere, but none actually present a complete picture of the process. They wind up resembling, as one survey respondant suggested, feeling like the old "how to draw an owl": Step 1) draw the eyes, Step 2) Draw everything else.
This might sound a bit stupid, but I was looking into F# a while ago (26 days ago, if the timestamps of the few files I wrote don't lie :-) ) and now I'm wondering I could have found those things (especially RWFP because I usually don't like learning from videos) if I start on fhsarp.org?
I did a post last year on writing websites in F#. I personally recommend doing everything up to the API layer in F# e.g. restfully, and sticking to something like typescript on the client side. If you want a full F# end-to-end story check out something like Websharper or one of the F# <> JS cross compilers.
Rather than disagreeing, it might be helpful if you suggest a few complete (but simple) application tutorials written in F#. I'd be interested in that too.
What I mean is writing a desktop application without falling back to using C# for all the front-end code and relegating F# to being a glorified DSL for data processing.
Microsoft doesn't believe anyone wants to make apps in F#; Visual Studio doesn't even come with templates for it. You're expected to use F# to write libraries like Fsharp.Data, and write your app code in C#.
If I wanted to code in C#, I'd code in C#, but I don't.
A desktop app on Windows either uses WPF or WinForms. In either case F# doesn't stop at all. In fact I would say that building WPF desktop on F# is more intuitive than C#.
open System.Windows.Forms
[<EntryPoint>]
let main argv =
let form = new Form()
let button = new Button()
button.Text <- "Click me"
button.Click.Add (fun _ -> MessageBox.Show "Hello" |> ignore)
form.Controls.Add button
Application.Run form
0
My "WPF Image Cropper" sample might be interesting to you - pure F# WPF via XAML type provider. I am not a GUI dev, though, so it's probably crap design :)
I would also like to add that F# is functional, imperative & OOP language. If any program uses any combination of these, it is still the F# code. But I agree there has to be more taste of "F#" since it is a functional first language.
I love F#, and I was looking at Idris for a more functional program verification, theorem-proving language. Then I stumbled upon F* (Fstar) - https://www.fstar-lang.org/
It is like F# but uses the Z3 solver, and is very ML like.
I find more trivial examples and exploratory code out there (using type providers, etc), than complete examples that show best practices -- at least for web development.
I haven't come across any complete examples for simple web applications without too many dependencies that you can easily learn from
Have you looked at http://fsharpforfunandprofit.com/ ? This site contains lots of useful information and would be enough to get started. Another possibility is to read a few books, e.g., Expert F# 3.0, F# Deep Dives.
F# Journal articles walk through the design and implementation of dozens of different example applications including both client GUI and server with sockets and so on.
Interesting note from TIOBE about F# just yesterday:
March Headline: All time high for F# at position 11
Microsoft's programming language F# is about to sneak into the top 10. It is not clear why F# is gaining popularity. Possible reasons might be the F# web-programming framework WebSharper and the promotional work of the F# Software Foundation as Tomas Petricek (author of "F# Deep Dives") stated in an interview about 2 weeks ago.
Well, they basically concern themselves with the ranking and when an unpopular lang hits an historical high or low, they make it into headlines.
Just for the record, this month's headline (for the sake of Scala's position)
April Headline: Java back at the top!
Java is back at the top of the TIOBE index after one and half year. Androids ongoing success is probably the major reason for Java's revival. The Java language has been in slow decline for many years now, mainly due to its waning foot print in the enterprise server back end market. Since October last year the increasing demand on Java Android programming has exceeded this decline, thus pushing Java more than 3% during this period. Another interesting move this month concerns Scala. The functional programming language jumps to position 25 after having been between position 30 and 50 for many years. Scala seems to be ready to enter the top 20 for the first time in history.
That hiring myth is a killer. Project I'm helping on would have been much better off with F#. But the CTO is very scared they wouldn't find "F# developers". Despite any C# dev worth hiring would not have a problem learning. Despite that his second hire just happens to know F# anyways.
There was also concern that "valuation of the company might tank due to use of non-standard code".
I think these are incorrect ideas. I'd take some pay cut to work on F# code instead of C#. Everytime I write anything in C#, I keep thinking how easier and shorter it'd be in F#. Just this week, we lost a whole day to a mutation bug:
inputParam.Bar = Baz // oops, now we just updated the callers notion of that .Bar property
Yeah, we coulda caught it in code review. We could have tried to make things readonly, but C# 5 still doesn't have a simple readonly record concept like F#.
I'd guess that if you advertise an F# job you're going to get more good replies, because people want to work on F#. And you can still leverage someone's knowledge of .NET, the frameworks and libraries and all that. So it's less risky than using, say, Haskell, where you're all alone - F#'s still compiling and consuming IL even with all its magic on top.
When I was 7 years younger, I predicted that obviously F# will take over at least 20% of C# development 2010 - it was just too awesome for people to ignore. There was no reason _not_ to use it apart from legacy or bad management, but no one could ignore such benefits. I have, uh, recalibrated since.
(The biggest technical hurdle I had was frameworks that didn't target .NET, but targeted C#. They'd depend on undocumented output of the C# compiler expression trees. Those were a bit of a pain to fix, but not too hard. Another annoying thing is the MVC teams decision, since C# doesn't have tuples, and dictionary creation syntax is too clunky, to pass arbitrary types as parameters (@Html.Foo(new { this="is", just="some", anon="type" }). Then they go using reflection to inspect the properties of the type. That's just dumb and has caused tons of bugs. And would have been avoided had C# a nice way to write lists or tuples or something. But the MVC team wanted it to "feel like Ruby". This isn't _hard_ in F#, it just looks as bad as it is.
I have tried to convince my manager to let us implement chunks of F# code into our projects. It would make development times much shorter and reduce complexities in our application. Despite his personal interest in functional programming, he is still hesitant to incorporate it.
I've been working with the language for a few months. Overall, I love pretty much every single aspect of the language. I am even starting to feel like the few things that I would like to have aren't necessary (such as HKTs and ML-style functors). In terms of platform support, F# has done almost everything right (I feel like Scala made boat loads of bad compromises to support Java interop, which I don't find at all with F#). There are entire classes of frameworks for web and mobile development in C# that are made obsolete even by the simplest language-level features like Agents, ADTs, Computation Expressions, Active Patterns, Type Providers, etc.
My disappointments so far are super frustrating though. Like Jarcane, I've found quantity of documentation to be an issue. Most tutorials assume that you a) already know C# and b) are using VisualStudio, and the whole ecosystem is still very Windows-centric. It is nearly impossible to learn the language without an IDE, and all of the non-VS IDEs are pretty crappy in terms of F# support. The whole msbuild or whatever it is behind the scenes doing the building is completely opaque and incomprehensible. The compilation order issue (you basically have to tell the build system the order of compilation, with no cyclical dependencies) is pretty difficult to understand and sometimes very difficult to work with. It also makes code organization very unintuitive (you can't put code in directories?!).
All in all, it is pretty frustrating, but at least they got the language right. The frustrations will likely go away in time, so I'm willing to put up with them for now. Maybe I'll get good enough at the language to actually fix them :)
Something that's kept me from pursuing learning F# is whether I need to know C# and/or Windows development, plus concerns about lacking access to Visual Studio.
I'm learning Scala now and found that it's relatively approachable without knowing Java, but Clojure was definitely easier to approach from the "never used Java" perspective. But it seems like F# is a much bigger leap to make for someone with no MS stack experience than Scala/Clojure for someone with no JVM experience.
It seems like Scala and F# are the only real choices for typed functional languages in relatively common use in industry (in comparison to Haskell and OCaml).
You definitely do not need to know C#. Knowledge of the .NET Framework or Mono is however desirable (which if you do not know C#, you are unlikely to have) in order to get things done.
I use LinqPad for writing small to medium size F# programs. There is also another IDE called Tsunami for F#, its useful and lightweight. MonoDevelop does run F# but you have to get that as a plug-in after installing on Linux and OS X. Atom has a F# package, but I have not used it. Of course, fsi (interactive) is probably best kept secret while learning the language or playing a new library.
Is there any support for type providers or code completion for F# in LinqPad? I was (mistakenly) under the impression that F# wasn't supported, so spent most of my time inside of VS and Xamarin Studio for the goodness of type provider intellisense.
No there is no intellisense in LinqPad, interestingly tryfsharp.org has the online editor that seem to excel with intellisense esp. while using IE for type providers.
I made a language safety score to help explain F# to myself and coworkers, and its helped make strong inroads with them. With the defaults, F# is as close to C# in safety as C# is to JavaScript. http://deliberate-software.com/programming-language-safety-a...
I would say F# is much safer than C# as it has immutability by default, non-nullable reference types, Option types, units of measure, and stricter casting rules.
47 comments
[ 3.4 ms ] story [ 93.0 ms ] threadThere's scattered bits here and there elsewhere, but none actually present a complete picture of the process. They wind up resembling, as one survey respondant suggested, feeling like the old "how to draw an owl": Step 1) draw the eyes, Step 2) Draw everything else.
"Real World Functional Programming" - https://msdn.microsoft.com/en-us/library/vstudio/hh314518%28...
Some higher level presentations - https://channel9.msdn.com/Tags/fsharp
Then there are the Erik Meijer teaching FP series, even though they are based on Haskell, given their ML common roots is also a good series to follow.
http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Func...
http://fsharp.org/about/learning.html does not list them, and going from http://fsharp.org/about/index.html via the "Language Reference" link to https://msdn.microsoft.com/en-us/library/dd233181.aspx doesn't list RWFP in the sidebar anymore.
https://cockneycoder.wordpress.com/2014/09/03/lightweight-we...
The F# News blog has had many applications on it:
http://fsharpnews.blogspot.co.uk/2010/12/most-popular-f-samp...
So has Phil Trelford's blog:
http://trelford.com/blog/
And many others.
Majority of providers in FSharp.Data [1] are idiomatic F# code (also contains imperative & a bit of C#ness to use lib outside F#)
1. http://fsharp.github.io/FSharp.Data/
Microsoft doesn't believe anyone wants to make apps in F#; Visual Studio doesn't even come with templates for it. You're expected to use F# to write libraries like Fsharp.Data, and write your app code in C#.
If I wanted to code in C#, I'd code in C#, but I don't.
https://code.msdn.microsoft.com/site/search?f%5B0%5D.Type=Pr...
My "WPF Image Cropper" sample might be interesting to you - pure F# WPF via XAML type provider. I am not a GUI dev, though, so it's probably crap design :)
And then there is also WebSharper http://websharper.com/
I haven't come across any complete examples for simple web applications without too many dependencies that you can easily learn from
I guess you gotta be anal to do data.
March Headline: All time high for F# at position 11
Microsoft's programming language F# is about to sneak into the top 10. It is not clear why F# is gaining popularity. Possible reasons might be the F# web-programming framework WebSharper and the promotional work of the F# Software Foundation as Tomas Petricek (author of "F# Deep Dives") stated in an interview about 2 weeks ago.
The Tiobe score for F# improved by +0.23% (which might be from March 2015 to April 2015).
afaict the data tables for previous months are unavailable, and not recoverable from the Internet Archive because of the way the data is displayed.
April Headline: Java back at the top!
Java is back at the top of the TIOBE index after one and half year. Androids ongoing success is probably the major reason for Java's revival. The Java language has been in slow decline for many years now, mainly due to its waning foot print in the enterprise server back end market. Since October last year the increasing demand on Java Android programming has exceeded this decline, thus pushing Java more than 3% during this period. Another interesting move this month concerns Scala. The functional programming language jumps to position 25 after having been between position 30 and 50 for many years. Scala seems to be ready to enter the top 20 for the first time in history.
There was also concern that "valuation of the company might tank due to use of non-standard code".
I think these are incorrect ideas. I'd take some pay cut to work on F# code instead of C#. Everytime I write anything in C#, I keep thinking how easier and shorter it'd be in F#. Just this week, we lost a whole day to a mutation bug:
Yeah, we coulda caught it in code review. We could have tried to make things readonly, but C# 5 still doesn't have a simple readonly record concept like F#.I'd guess that if you advertise an F# job you're going to get more good replies, because people want to work on F#. And you can still leverage someone's knowledge of .NET, the frameworks and libraries and all that. So it's less risky than using, say, Haskell, where you're all alone - F#'s still compiling and consuming IL even with all its magic on top.
When I was 7 years younger, I predicted that obviously F# will take over at least 20% of C# development 2010 - it was just too awesome for people to ignore. There was no reason _not_ to use it apart from legacy or bad management, but no one could ignore such benefits. I have, uh, recalibrated since.
(The biggest technical hurdle I had was frameworks that didn't target .NET, but targeted C#. They'd depend on undocumented output of the C# compiler expression trees. Those were a bit of a pain to fix, but not too hard. Another annoying thing is the MVC teams decision, since C# doesn't have tuples, and dictionary creation syntax is too clunky, to pass arbitrary types as parameters (@Html.Foo(new { this="is", just="some", anon="type" }). Then they go using reflection to inspect the properties of the type. That's just dumb and has caused tons of bugs. And would have been avoided had C# a nice way to write lists or tuples or something. But the MVC team wanted it to "feel like Ruby". This isn't _hard_ in F#, it just looks as bad as it is.
My disappointments so far are super frustrating though. Like Jarcane, I've found quantity of documentation to be an issue. Most tutorials assume that you a) already know C# and b) are using VisualStudio, and the whole ecosystem is still very Windows-centric. It is nearly impossible to learn the language without an IDE, and all of the non-VS IDEs are pretty crappy in terms of F# support. The whole msbuild or whatever it is behind the scenes doing the building is completely opaque and incomprehensible. The compilation order issue (you basically have to tell the build system the order of compilation, with no cyclical dependencies) is pretty difficult to understand and sometimes very difficult to work with. It also makes code organization very unintuitive (you can't put code in directories?!).
All in all, it is pretty frustrating, but at least they got the language right. The frustrations will likely go away in time, so I'm willing to put up with them for now. Maybe I'll get good enough at the language to actually fix them :)
I'm learning Scala now and found that it's relatively approachable without knowing Java, but Clojure was definitely easier to approach from the "never used Java" perspective. But it seems like F# is a much bigger leap to make for someone with no MS stack experience than Scala/Clojure for someone with no JVM experience.
It seems like Scala and F# are the only real choices for typed functional languages in relatively common use in industry (in comparison to Haskell and OCaml).
Learning on anything other than Visual Studio will probably be challenging. You know you can get full Visual Studio 203 for free now? https://www.visualstudio.com/en-us/products/visual-studio-co...
[1] http://blog.zolomon.com/development,emacs/2015/03/25/emacs-o...
https://www.coursera.org/course/proglang
I would say that if I can use F# Data or Deedle on a project, I will. Those tools totally make it worth learning a little F#.
http://bluemountaincapital.github.io/Deedle/ http://fsharp.github.io/FSharp.Data/