CompGuy101 wrote:
What can F# do that I cannot do in VB / C#?
Quick answer a lot.
One quick example tuples.
let x = ("bob", 100)
Basically creating a new record type out of thin air.
Not fancy enough?
(From Don's book)
http://www.amazon.com/Expert-F-Don-Syme/dp/1590598504Partial Application
let shift (dx,dy) (px,py) = (px + dx, py + dy)
So functions are just like any other variable shift takes two parameters that are tuples what is right of = is the function definition.
Four functions that use Partial application:
let shiftRight = shift (1,0)
let shiftUp = shift (0,1)
let shiftLeft = shift (-1,0)
let shiftDown = shift (0,-1)
Basically calculating the first tuple parameter (dx,dy) of shift then calling it via another function and providing the second tuple it at a later time when shift_________ is called.
Low noise branching (called Pattern matching '_' is wild card though you have if and else and ifel):
let urlFilter url agent =
match (url,agent) with
| "http://www.control.org", 99 -> true
| "http://www.kaos.org" , _ -> false
| _, 86 -> true
| _ -> false
You would have to nest switches or make messy if else soup to do that in C#/vb
The f# compile throws warning when a previous pattern would be used thus some pattern is unreachable which is useful.
Again I recommend reading Expert F# as it is very well written read it in like a week. Saying it is anything like C# and VB.NET is well saying Javascript is fairly close to Java.
I will be writing more on my blog for sure. Now will I be using it for all new development probably not but it has many advantages over C# and is something to watch like Ruby.