Hi,

you've allready got your answer that F# won't do anything special here so maybe I can give some further insight(?).

As you said you can parallelize this algorithm rather easy but just thing about how you would do this. First you would note that there are 1000 numbers to add and you've got (say) 4 CPUs in your system, so of course each should sum 250 numbers and then a single one should sum the remaining 4 - right? (Well you might indeed want to make those packets smaller because one CPU might do other work and so on - but never mind that for the moment).

So what would the F# need do know to make really good code for you? Well first a simple thing: the length of this sequence - but wait! Sequenzes might have no length at all (seq of all numbers) or the lenght might be determined only at runtime .... well the compiler is in trouble here.

Then the complier might even need to know the numbers of cores you have in your system - or should the compiler give you some code that is deciding this at runtime? Well the needed code gets nastier and nastier and this is only for your simple algorithm.

Now think of some "real" problem ...

But why be disapointed? I guess the minute any complier might handle such stuff in a reasonable way is the day when software development gets either boring or obsolete ;)

By on 11/9/2010 9:25 PM ()

F# doesn't do any multi-threading on your behalf, you have to code it. Libraries like TPL and things like Async.Parallel are good for expressing parallelism at a high level, so that you don't have to think in terms of 'threads'.

By on 11/9/2010 8:16 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