You should see good preformance with F# whatever you do. F# is a compiled rather than interpreted language. First the source is compiled to IL (intermediate language) then when executed it is "just in time" compiled to native code. The code is optimized at both compilation phazes. Although the JIT compilations add some overhead, the resulting code executes very quickly. Code that is executed repeatedly, such as any kind of loop, is likely to see most benefit as the cost of JIT compilation will be amortized quickly.

If your really interested in getting the most out of F# and the CLR platform there are lost of resouces on how the CLR works and how to tune it, although most of the time this probably won't be necessary. One great blog is "Rico Mariani's Performance Tidbits":
[link:blogs.msdn.com]

I'd also recommend "CLR via C#" by Jeffrey Richter:
[link:www.amazon.com]

By on 1/25/2008 11:47 PM ()

Robert,

Thanks for the information and recommendations. Mathematica is interpreted, so it makes sense that loops could be a problem. However in addition I believe that the internal functions were optimized to the best of their ability. I guess I was wondering about F#, whether internal routines might be better opitimized. For example consider Set.of_list. If I were to write the best possible code in F# to implement that, would it be as fast as Set.of_list itself? Obviously I'd have no intentions of trying to write that code myself. But this sort of thing might have some impact on the manner in which I code things. Sort of like when I'm driving my car I might go out of my way to travel on a highway, because in the long run it will save me time.

By the way, one of the members here recommended your F# book. I went to Amazon to order it, but was somewhat put off by a couple of the reviews. However the next day I found that you had posted chapter 3 on the web. I printed it out and read it. I found it fantastically helpful and decided to purchase your book – which should arrive in a few days.

Thanks very much.

Mitchell

By on 1/26/2008 8:40 AM ()

The F# libraries are written in F# itself, so Set.of_list is written in F# and you could have written it yourself. The F# library source code is included in the distribution. Look in source/fslib/set.fs.

By on 1/27/2008 11:00 AM ()

Thanks. I think that clears it up for me.

By on 1/27/2008 2:49 PM ()

Hi,

I don't know Mathematica, so... and I am pretty new at functional programming. But:

I think seqence expressions will fit like a glove for generating infinite random numbers. Robert Pickering has a good section "Seqence Workflows" here: [link:www.infoq.com]

As for the operations on lists, arrays and sequences you should read up on the "standard" functions like map, fold, filter etc. I usually write Seq. or List. in Vistual Studio and examine the documentation that pops up.

An example (Taken from Don Symes "Expert F#) is summing integers in a seq with fold

> Seq.fold (fun acc x -> acc + x) 0 [1; 2; 3; 4];;
val it : int = 10

Hopes this helps a bit
Best regards,
Jacob

By on 1/25/2008 3:31 PM ()

I've started blogging my learnings as I work my way through the list namespace. One of the great things about F# so far is it comes with the source code, so you get some great examples. Take a look if you're interested:

[link:natehoellein.blogspot.com]

By on 1/26/2008 8:40 AM ()

Nate,

Thanks very much, I'll take a look at, and hopefully learn from your experience.

Mitchell

By on 1/27/2008 2:48 PM ()

Jacob,

Thanks for the advice and the sample line. I just received Don Syme's book – actually about 2 hours ago. I'll go ahead and take a look at Pickering's article. I just started this a few days ago and it seems to be a very rich topic. There's a lot to look at. I'll take a look at "Seq" sometime in the next few hours.

Thanks again,

Mitchell

By on 1/25/2008 6:18 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper