Monday, June 14, 2010 5:25 PM
F# Discoveries This Week 06/14/2010 - TechEd Edition
Despite the small number of talks on F#, it seemed the language was on everyone’s lips this TechEd. Whether working at the Visual Studio Languages booth or hanging out at the parties afterward, almost everyone I talked to was actively investigating or making plans to explore the language.
Of course, this is great news. A quiet tide of interest is quickly rising. Now we just need to give those who are interested the resources they need to be successful and comfortable using F#.
For this reason, each and every F# speaker and blogger is critically important right now. If you haven’t, don’t be afraid to give blogging a try. The F# community is helpful and very forgiving of mistakes. If you are already blogging, consider giving a talk at your local user group or code camp. Now is the best time to help and educate.
Video / Audio
The TechEd talk covered a number of interesting aspects of using F# in Visual Studio - tools, core syntax, some examples of current commercial users, and the physical structure of F# projects used in client applications. But the theme of scaling from explorative programming to .NET component is one that I find particularly powerful, and which is a really unique strength of the F# language.
John Hughes is the author of “Why functional programming matters” paper and in this interview he outlines the merits of functional programming and the reason for his involvement with it. He also goes over several core principles of functional programming like monads, handling of side-effects, etc.
This week see's Richard talking with Joel Pobar about F# and languages in general. Functional programming is coming more and more to the fore and this is a great episode to find out more about F#, try and get your head around monads and think more about the way you approach programming in general and wether the general purpose languages that you use currently are always the best choice for the job at hand.
This article takes a look at some of the core concepts of the F# language and its implementation on top of the CLR.
Stephen Wolfram’s book, “A New Kind of Science” is flippin’ brilliant! (or perhaps I'm just not brilliant enough to realize he's a mad man) 1,280 pages packed with beautiful insights and Tufte-worthy visualizations. I remember discovering it while randomly browsing the MS library one day. I became so enthralled, an hour passed just standing there reading it!
One of the best areas to use a functional language is to apply it to symbolic calculations. Like transforming algebraic expressions or evaluating function derivatives. I remember how I was impressed many years ago when I looked at a program in Prolog that occupied not more than one computer screen but could tell me that derivative of sin(x) was cos(x). So I wanted to do the same in F#.
Now that WebSharper has been released and matured, it will be great to see it used more widely by F# users. Given the importance of both HTML5 and Silverlight, F# users interested in shipping visualization apps should really make sure they know how to use F# to program these, using the Silverlight SDK (for Silverlight) or tools such as WebSharper (for HTML5).
Once he went into the theory behind active patterns I agreed that the limit was reasonable and didn't push for us to change the design. This doesn't mean you can't use active patterns with greater than seven tags, it just means that you need to use a different language construct -- the partial active pattern -- instead.
The F# compiler includes a Units of Measure feature which infers a measure type at compile time, which means you get measure type safety with uncompromised runtime performance. […] Sometimes you might also want to actually infer units of measure at runtime, say to display the inferred unit type at the UI. The following F# code prototype provides such inference.
The sample demonstrates creating a View in WPF or Silverlight without XAML. The idea is to make things a little easier from F# by implementing a (+) operator overload to attach dependency properties.
If you’d like to take a look at the service I wrote, I published it on Visual Studio Gallery. You just need to go to File\New Project in Visual Studio 2010:
Dragon curves are a family of self-similar fractal curves. The following 17-line F# program uses Windows Presentation Foundation to visualize the results of a simple recursively-constructed dragon curve.
I had a situation come up in my proof-of-concept where I needed to do a collect on a .NET List<>. So I did some experiments with how it might best be accomplished. A key factor was that this is something that may be done literally millions of times a day if the application makes it to deployment; so I was concerned with performance.
The methods for compiling a set of finite automata DFAs or NFAs into a composite DFA are found in most introductory compiler texts. But how easy is it to construct a simple engine in F# which recognizes a series of patterns? As it turns out, pretty simple.
It turns out that I like the RWFP approach better than mine, but the special tuple pipelines I came up with are not without interest, so I decided to post them here.
Neil Carrier’s This is why I love F# Part One and Part Two
I can’t imagine having any trouble explaining the operation of this program to someone with a basic knowledge of statistics but no computer programming experience. It simply looks like what it does in a way that is succinct and comprehensible.
In the interest of building up a larger set of installed templates for F#, I've ported the standard C# WCF Service Application to F# and packaged it into a .vsi file.
To interact with CouchDB, I primarily use Relax (a full featured ".NET API abstraction of CouchDB's (excellent) RESTful API"); however, I thought it might be fun and educational to create a simple CouchDB .NET API abstraction in F#. Note: The code provided here is loosely based on SharpCouch.
During my professional career I often met the task of code generation based on some source data. Last time it was analogue of BCL compiler for ExpressionTrees and then C# compiler have done mostly all the required job with parsing expressions.
As you see compiler have inlined code of Trigger method inside Run and accessed field multicast directly. That’s why we replaced let binding with val.
One of my side-projects is GLSL Minifier. GLSL is the shading language of OpenGL, that is a language designed to run on the GPU, in order to control the graphics pipeline and create nice realtime graphical effects.
Many programs (especially console applications) need to parse the command line, and find which options the user want to set. As far as I know, .NET doesn't provide any function for this, but there several third-party libraries to do it.
As a functional programming language, F# programs are kind of high-level, thus harder to reason its performance than imperative programs. Not the big-O thing, it is the constant. This series contains little tips about performance.
I have been keeping my eye out for some examples of creating a WPF form in a F# project and came across Tim’s F# Twitter Stream Sample [..] So today I am going to make just the very basic WPF form with all the goodness of a XAML window.
In Thomas’s post he has a form with an ellipse on it that when he clicks on the ellipse it pops up a message box with the button clicked… awesome. Something that got me on the post though was the code similar to the one below…
The problem is that, an array is initialized per every rows, which wastes computational resource. Because the widths of each row are constant, why not make a 1d array and access pixels like y * width + x.
“Horrible performance. fibnaive 40 took 16.6 sec on my laptop" […] “It’s also pretty fast. Here are results of calculating 1000 Fibonacci numbers: Real: 00:00:00.001, CPU: 00:00:00.000, GC gen0: 0, gen1: 0, gen2: 0”