Friday, February 13, 2009 10:43 AM
Discoveries This Week 02/13/2009
A wide range of subjects this week including testing, concurrent performance, exception handing and data structures.
I feel that F#, with it’s concise syntax, is an ideal framework for writing tests. Combined with FsStory F# is made much more powerful in this regard as it becomes possible to write user case tests and have them read very much like simple English. F# has a huge advantage here over C# as it has much less syntactic cruft and so much less for your brain to process while reading. For example:
2: let MoveTurtleToPosition() =
3: given ATurtle
4: |> andGiven IsRotated90DegreesToTheRight
5: |> whens (TurtleWalksSteps 9)
6: |> thens (TurtleIsLocatedAt (0,9))
7: |> endStory
It’s obvious exactly what this is testing and how. Yet, it takes very little time to read. Very impressive.
While this post is rather old, I was very excited by Jan’s analysis of an article on comparing C# and F# using the distributed .NET computing framework Alchemi.
Optimizing this application showed that F# would finish in 1.5 seconds while C# would not complete any faster than 2.6 seconds.
It’s important to note that these results are a year old now and that with newer F# optimization the results might be even better.
The other interesting thing in this post is the discussion of the cost of heavyweight threads on the CLR. Which is directly related to our next discovery:
A first glimpse of that is in store for us in the next iterating of the Thread Pool. Not surprisingly, the optimizations seem to focus on sharing work across multiple threads.
With F#’s thread-friendly nature and new the optimized thread pool, I'm very excited to see how .NET compares to other grid computing platforms after it’s 4.0 release.
An informational post on managing and throwing both F# native and general .NET exceptions in F#. Included are examples of imperative style try, catch and try, finally patterns.
Rich Hickey, the father of the Clojure language, has gone out of his way to optimize Clojure’s structures for data sharing with immutability. I was very impressed with Clojure when, back last march, Rich Hickey came to Northampton and presented it in a talk. While, Clojure runs on the JVM and so comes along with all of the baggage that it entails, it’s a fantastic language and people in the java community are flocking to it.
I would love to see some of these data structures ported to the .NET framework so that F# could take advantage of them. As far as I am currently aware, F# data structures are instead implemented via binary trees and so are much less efficient in terms of the amount of data shared.