Question

I've heard a lot about functional programming languages and I'm willing to learn one. I guess it will be mostly for fun, however, I hope it will improve my programming skills.

I have mostly C#/.NET background, so my first choice is to learn F# (because of .NET and familiarity with Visual Studio). On the on other hand, I wonder if F# has features like Lisp macros or Haskell higher order functions.

Could you compare F#, Haskell and Lisp? Which one will be the language of your choice?

Was it helpful?

Solution

F# is my language of choice, but I'd strongly recommend learning them all. They are all quite different and interesting in their own right. Here's a quick over view to each one (with perhaps a slight F# bias), you can easily find more info by googling:

F# - is a language that makes it easy to program in the functional style, lets you easily copy objects rather than mutating them. It also gives you interesting data types, like tuples and algebraic data types, useful language constructs such as pattern matching and list comprehensions. It also has OO and imperative features and good access to libraries, since you can use any .NET framework component.

Haskell - is a pure and lazy functional language, making a rare or even unique beast. This means there are no side effects at all, unless they are tracked by a monad. Haskel too has tuples, algebraic data and pattern matching.

Lisp - whereas F# and Haskell are statically typed, lisp is dynamically typed. It has distinctive syntax which uses lots of parentheses and provides an interesting macro feature that allows you to make transformations to the program itself and extend the syntax.

OTHER TIPS

I had the same question once

Since then, I have done some programming in F#. Now I am very glad I did, since it is realy helpful to understand LINQ in C# and that happened to be my background too. (I almost never use foreach in C# now since I learned F#)

I learned through F# a lot of things about lazy evalution, lists and sequences, all of which you could pick any language for with good support for lists, tuples, and so on (like any functional language I guess), but if you pick F#, all of this will be very useful in C# too. Maybe you already know all of this stuff and use it right, but in case you don't, pick F#.

I started out here : a very nice video tutorial, very impressive and a very inspiring tutor.

Currently I'm watching these video's on Channel 9 on the basics of Functional programming. It's explained using Haskell, but the basics apply to all languages. I must say it's very informative and easy to understand.

This is a very subjective question.

My opinion is that Scheme (a Lisp variant) and reading SICP is the right thing. You will learn a lot.

But for practical purposes and if you are a .NET developer then maybe F# is better.

I don't know F# but I like to play with it sometimes. My language is Clojure which is very functional and works on the CLR too, but the JVM version is the main version.

It overs you a lot of the stuff you want. The main diffrence to F# is that Clojure is dynamicly typed and it has really good way handle concurency (one of the best I would say).

BTW. Did you know that F# was made because Haskell was to hard to get running on the CLR? (Thats not the whole story of course but its part of it)

Nobody actually answered this specific question: "I wonder if F# has features like Lisp macros or Haskell higher order functions."

F# does not offer macros. Also, it does not offer higher-kinded types (which is what I thought you were asking at first).

F# does offer higher-order functions in that you can easily write a function that takes a function and returns a function. In fact, C# (or really any .NET language) can do this as the Func delegate is part of the .NET framework.

Why choose? Learn both Lisp and Haskell on your own. No point in learning F# on your own time though. If you need it for work, you'll learn it at work ;)

EDIT: The guy was looking at language to learn for fun. Well, Lisp and Haskell are good candidates since fun is all they are going to be used for (no paid jobs there). He "might" (although unlikely) have opportunity to use F# at work (he is in MS shop), so why learning something in free time when he can be paid learning it at work.

I learned all of them to a diffeent degree, and would advise starting with Scheme (a Lisp dialect) - simply because it is easiest to learn. Haskell and F# are statically typed, which is a big advantage for real-life projects, but IMHO they have a little "too much" syntax and are not as easy to pick up as Scheme.

There is a nice Scheme implementation for .NET - IronScheme. You can take a look at my article "Playing with IronScheme" to see if you like it.

If We compare this three languages I'll recommend Haskell. It is more practical than LISP I think (because it's type system) and more powerful and clever than F#. As far as you know F# is a .NET port of OCaml and to some extent it is not ideoligally clear as Haskell is or as OCaml is. I'll recommend you study Haskell or OCaml to know how inconvinient F# is.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top