Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm coming from Linux and Ruby. I've been interested in learning more functional programming, and in particular the ML-ish style. I've tried reading through the Real World Haskell book and trying some Haskell that way. But it's hard to learn this way for me because Haskell is very weird to me and I don't think I'll manage to really learn it until I try to do something real with it.

That's why I'm considering learning F# instead, because I'm guessing that this way I can kill two birds with one stone: learn an ML-style functional language paradigm, and also learn Windows programming APIs (.NET libraries). This seems to be a more productive route than learning the Haskell library counterparts of all the Ruby libraries I've grown to love, but staying within the Linux/OSX universe.

My question is, how sound is this reasoning? Is F# an adequate substitute for Haskell if you want to learn the programming ideas and techniques that Haskell teaches you?

share|improve this question
2  
Though not a direct answer, as @Jetti remarked, it seems you really want to learn Haskell. You may find Learn You A Haskell a more friendly introduction. –  Zach L Oct 7 '11 at 18:48
    
Depends entirely upon what you mean by "important functional programming concepts of Haskell". Are you referring to purity or non-strict evaluation or type classes or monads or...? F# has some of these concepts. –  Jon Harrop Feb 24 '12 at 11:25
add comment

2 Answers

up vote 5 down vote accepted

The biggest conceptual leap in Haskell compared to other languages are that it is pure and non-strict (lazy) and the monads and arrows abstractions that are used to implement inherently sequential operations in that world.

F# is neither. You can learn to work with higher order functions and common functional abstractions like map and reduce there, but all those things are available in ruby and python as well. And the advanced stuff is unique to Haskell.

Also F# uses .Net as it's standard library and that was designed for procedural languages (and it's not outstanding anyway; there are better frameworks out there), so you will quite likely find you are not actually writing much functional code anyway. From this point of view if you want to learn functional programming but don't feel ready for the big jump to Haskell, OCaml or one of the classics, Common Lisp or Scheme are preferable.

On a side-note, F# can be used on Unix as well with Mono, but on the other hand Ruby, OCaml or Haskell can be equally well used on Windows.

share|improve this answer
    
If I want to learn .NET programming then, would you say that C# is just as good as F# (and probably easier for me to learn)? –  dan Oct 7 '11 at 20:16
    
@dan: I think yes. The runtime library is the same, so the difference between C#, VB and F# mostly boils down to syntactic sugar. F# is less verbose, but more different from languages you are used to and even C# has lambda expressions and list comprehensions, though with slightly weird syntax (using sql-derived keywords, but different order). –  Jan Hudec Oct 7 '11 at 20:36
    
I think then that I should just try to find a practical problem I can solve with Haskell on Linux or OS X. –  dan Oct 7 '11 at 20:45
1  
The difference between F# and C# is far from just syntactic sugar. For example the way it handles monads. You don't have to use monads for IO in F#, but you can use them for very interesting things like async. –  svick Oct 10 '11 at 18:21
add comment

Is F# an adequate substitute for Haskell if you want to learn the programming ideas and techniques that Haskell teaches you? Which would be what? Are you looking for the things that Functional Programming teaches in general or just Haskell?

and also learn Windows programming APIs (.NET libraries).

There is nothing wrong with learning F# as it is a fun language to use but I would be careful about learning the .Net API in F# as there isn't as many code samples in the MSDN documentation. Most of the times I've looked, the F# example is missing.

This seems to be a more productive route than learning the Haskell library counterparts of all the Ruby libraries I've grown to love, but staying within the Linux/OSX universe.

If you want to stay in the *nix realm, check out OCaml. It is part of the ML-family and has syntax that is very similar to F#.

One question: why the need to learn Haskell? It seems like you're very focused on it.

share|improve this answer
    
I don't need to learn Haskell. Just something different enough from Ruby and JavaScript, which I do a lot of. I tried Clojure for a while, but I just accepted the fact that I can't stand Lisp syntax. –  dan Oct 7 '11 at 20:12
    
@dan: Learning .Net won't be too different from Ruby and JavaScript, whether you use it with F#, C# or VB. Either stay set on Haskell, pick something still very functional like OCaml, or you could try some lower level multi-paradigm language like C++ or D. –  Jan Hudec Oct 7 '11 at 20:46
    
OK I think I will give Haskell a serious go. I now have a problem I think it will be good to try using Haskell for. –  dan Oct 7 '11 at 20:53
    
What do you mean, there isn't much documentation? .Net part of MSDN is one of the best documentations I have ever seen. –  svick Oct 10 '11 at 18:22
    
@svick - I'll edit my response, but I meant code samples, not documentation. Thanks for pointing that out. Most of the MSDN docs I've looked through don't have an F# example. –  Jetti Oct 10 '11 at 18:34
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.