Saturday, August 24, 2013

From a high level programming perspective, what is the major difference between C# and F#?

From a high level programming perspective, what is the major difference
between C# and F#?

I'm aware that they both use different programming paradigms, but from a
high level perspective apart from differing syntax it seems most basic
tasks can be achieved in similar fashion.
I only say this because when I've previously touched functional
programming languages such as Haskell, writing code for basics tasks was
(at first) difficult, frustrating, and required a completely different
mindset.
For example the following took some time to get to grips with using
recursive syntax:
loop :: Int -> IO ()
loop n = if 0 == n then return () else loop (n-1)
Where as an F# loop is recognisable and understable almost immediately:
let list1 = [ 1; 5; 100; 450; 788 ]
for i in list1 do
printfn "%d" i
When C# programmers start learning F# they are advised to completely
re-think their thought pattern (which was definitely required for
Haskell), but I've now written several F# programs dealing with
conditions, loops, data sets etc to perform practical tasks, and I'm
wondering where the 'different-paradigm' barrier really kicks in?
Hopefully someone will be able to solve my confusion.

No comments:

Post a Comment