Inside F#

Brian's thoughts on F# and .NET

Where did Brian go?

Posted by Brian on February 5, 2009

After three or four months of blogging about once per week, all of a sudden I disappeared for more than 9 weeks.  What gives?

As you may have guessed, in addition to being away for the holidays, I’ve been busy working on integrating F# into Visual Studio 2010 (and at the same time, improving F# atop VS 2008, since we will continue to ship out-of-band releases of F# before VS 2010 ships).  It’s been good to be focused at work, but I’ve been feeling very guilty about not blogging, so I decided to post a ‘softball’ entry today, in the hopes of gaining some blog-momentum back.  What’s today’s topic?  Why it’s lambdacats of course!

Lambdacats are like LOLcats except that they use obscure functional programming humor.  (Thanks to Matt for pointing them out to me.)  A typical example that’s right up my alley is


which plays off the facts that catamorphisms are sometimes written using (|banana-clips|) syntax.  Trust me, it’s very funny.  :)

I have a number of ideas for future blog posts… it’s just about making the time to actually write them.  For example, a couple months ago, after seeing this site, I had to try my hand at a similar problem, yielding results like these

TriBri1 TriBri2

Those of you on StackOverflow may recognize that as my gravatar; indeed that’s what I was using for test cases to tweak my algorithm:

TriSO1 TriSO2

Fun!  So of course I want to blog about that (about 300 lines of F#).

I also would like to finish off this series describing the relationship between C# and F# code.

I’d also like to write about modules, namespaces, and programming at the F# top-level, to help answer questions like these.

What would you like to see?

Still alive,



4 Responses to “Where did Brian go?”

  1. Larry Smith said

    I\’d like to see two things, aimed at the beginner F# (but with lots of coding experience) programmer (moi).First, larger sample programs, using as many features of the language as possible (with annotations, of course). For example, I needed recursive data structures. "Expert F#" had it. In 3 lines at the bottom of page 67. So easy to miss. But I found it in an online sample. In the same vein, later I also needed to create a new instance of class foo from the constructor for class goo, and pass a refrence to goo to it. In C# I\’d say public goo { … foo(this, …) }. But how to do that in F#? Again, I stumbled across how to do it in an online example, wich had "new() as this = …".But the major thing I want is "A C# (and .NET Framework) programmer\’s Guide to F#". (Yes, I know there are a (very) small number of web pages that talk about that, but they\’re not enough.) Along the lines of "here\’s a common thing in C#", now "here\’s how you can do it in F#" (along with, ideally, "here\’s a better way to approach it functionally"). But also some really fundamental things. Like the fact that the fact that an "if" statement in F# *returns a value!*, rather than just defining flow of control. In that sense, it\’s much closer to C#\’s ?: trinary operator.I guess what\’s really bugging me is that Expert F# is just so frustrating for a beginner. They throw undefined terms around with abandon (e.g. on page 13 they mention "option" and "Some", with no explanation — and it still took an example on a web page to figure out how to actually *use* it, and to realize that it\’s really similar to Nullable<T>). The description of function types (e.g. int -> int) is OK. That is, until you come across int -> int -> int. I wound up deducing currying (mentioned in the Index (don\’t get me started about the Index) on page 559!) as the only possible explanation for this weirdness, long before I saw the explanation in print. But meanwhile, the book blithely throws this (initially nonsensical) syntax at you. And tuples. Some examples show text with parens around them, making them tuples. Others (especially (only?)) on the LHS of "=" sometimes show them with and sometimes without. When are they needed, and when are they suprfluous? I finally figured out that when you\’re calling a .NET library routine, you\’ve got to pass a tuple, so that technically you\’re passing only one argument to the function. But, for example, what\’s the difference between <x> and <(x)>. Is the latter a tuple? And <seq> vs <Seq>? OK, I now know that the first\’s another way of saying IEnumerable, and the other is a module, with Seq.to_list being the to_list method in the Seq module. But man, that wasn\’t clear until much later.I could go on and on. But really, Expert F#\’s authors are kidding themselves if they think that the introductory material they give (as opposed to the latter parts of the book) is good. I wasted the equivalent of several days struggling with the language, just porting an existing small program over to F#.Don\’t get me too wrong. The book has many good points, but a tutorial it ain\’t. It\’s clearly written by people who know F# so well that they\’re unable to put themselves in the shoes of a newbie. If I were an experienced OCaml or Haskell programmer, this book would probably make a lot more sense to me. Still, I\’m glad I have it. And it was fun (albeit in a semi-masochistic sense) to fight this much with learning a new language (the challenge of it all). But I wouldn\’t wish this experience on most people. So anything you can do to bring people up to speed, in a gentler fashion, would be worth your time and ours.P.S. On a different matter, it was difficult to type, and especially review, this comment, since I\’ve got only 3 lines at a time displayed. So the above comments may be a bit more disorganized than I\’d like. Can you modify your Comments interface to give us more room?

  2. Domine said

    Hi Larry,Check this out:\’m slowly reading it; tons of comparative examples C# ~ F#. Might be what you\’re looking for. In any case, definitely a good book in my opinion (so far, I\’m reading it in parallel with two other F# books and some other stuff books so I have not read all the published chapters yet).I hope this helps.Regards, dfgPS.- I also found learning F# frustrating for some time. Until I came to terms with the fact that my Italian (C#) might help me learn some French (VB .NET) but it\’s almost useless when it comes to learning Russian (F#). So nowadays I sit on my desk, repeat to myself "I\’m a programming ignorant" three times, start VS, write some code in F# and learn something. Slow process, but so far it\’s paying off because most of the functional programming stuff is truly amazing and totally new. So bit by bit and step by step; I\’m hoping that one day, all of a sudden, the whole picture together will make sense. Fingers crossed… :-)

  3. Domine said

    "most of the functional programming stuff is truly amazing and totally new": I meant new to me, of course.

  4. Art said

    Templates, yes, to guide through that process. Using F#, VS\’08, ,NET 3.0, 3.5, DX, XNA, WPF, SL 1,2, need info F# v2.0, VS\’10, .NET 4, SL3 …Best practices for mouse events, GUI, display threadS, …"… F# users should use the Visual Studio designer tools to generate C# or Visual Basic code and incorporate those components into their F# applications. In Visual Studio 2010, we expect F# applications which include components built with designers (e.g. WinForms, ASP.NET, Silverlight and WPF applications with a designer front-end) will normally be authored as mixed language applications. We\’ll be providing templates that guide F# developers through this process. …"Thanks for your work, looking forward to new posts. Art

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: