tags:

views:

717

answers:

8

I am a C# programmer, and after going through some wonderful discussions regarding functional programming and declarative programming. I feel I am not good at both :P, so, I was thinking of starting learning prolog, and haskell. Please suggest about the feasibility in doing so. And if I learn F#, then learning Haskell makes any sense ? What qualities these languages would provide me which can help me in writing better c# programs ?

A: 

I don't think learning either of these languages will help you be a better C# programmer. I would spend my time practicing programming in C#.

Galwegian
locking yourself in a dark room and not speaking to anyone or learning anything new is also a great way to..... oh wait, thats bad isnt it, not good!
Andrew Bullock
+2  A: 

functional and logic(declarative) programming is another programming paradigm, you are thinking from another point of view.

But both paradigms may not have direct impact on your coding using c#, but it may be indirect when you are thinking in the problem itself

Ahmed Said
+5  A: 

There are very few languages X, if any for which you could not write a Reg Braithwaite approved post of the form "What I learned from Language X that makes me a better programmer when I use Language Y"

C# itself is accumulating a number of functional constructs -- lambda expressions and the System.Linq extension methods -- so learning to think functionally will definitely help you get the best out of the day-job language, as well as being fun in and of itself. As it happened Erlang was the first functional/pattern-matching language I picked up after C#, but that alone was enough to make me look again at my C# style and how I approached problems.

FP is becoming the next big thing, and there's no dearth of languages to look at and decide which suits you most for learning -- Haskell, Erlang, as well as newcomers F#, Scala & Clojure are all riding this wave.

Steve Gilham
+3  A: 

Learning functional programming coming from an imperative language like C# is very hard, its a completely new way of thinking (for me at least, you may find functional languages easier to understand! depends how your brain works ;))

F# would be a good choice because it sits on the CLR, this means you can use F# libraries you write from your C# code with ease.

F# is typically better suited to "functional" (mathematical) problems.

Im looking at rewriting some complex algorithms in my C# code with F# to make them faster and more succinct.

As Ahmed mentions. Learning to think about problems in a new way can only be beneficial!

Andrew Bullock
+3  A: 

I can NEVER hurt to learn a new language. I am going to butcher the quote, but the jist was "If you don't know how to write a thought, you don't know how to think the thought". It was in the context of natural language, but I think it applies to programming language too.

Take a look at prolog and haskell and tinker for a bit. It will, at the very least, add tools to your belt.

Andy_Vulhop
+2  A: 

Id start with prolog because its the easier of the two. Will give you a feel for a new paradigm. Then have a go at haskell or f#.

Id recommend f# over haskell since there is a easier to create libraries compatible with c# and .net in general hence making it more useful

Marcom
+2  A: 

I have seen the opinion here that it is better to start to learn prolog initially. I personally disagree. Functional programming is closer to what you can do in other languages. For instance in C++ you have a lot of approaches that come from a functional programming perspective (stl algorithms, boost::bind, boost::lambda, etc). I don't know C# but I've been told that it happens the same.

So I think it would be easier start with a functional language. I personally know haskell, scheme and prolog, and I thing that if you start straight away with unifications, spanning search, rules and so on it might blow up your mind a bit(it could blow up mine at least ;-) ). Again is just an opinion ...

fco.javier.sanz
I searched google in my attempt to make my first hello world prolog program. But all in vain. I have downloaded SWI-PROLOG but I am unable to guess how to write a file and then run(consult) it.
pokrate
+4  A: 
  1. Like the first time you went from imperative to object-oriented, working with functional programming requires a rewiring of how you think things out. The first time you tend to do things in a hybrid fashion until you get the gist of it all. Since you are coming from C# background, I would suggest trying F# as you are likely to get used to it much more quickly since the .net languages share a common framework which is good enough to get you started.

  2. That said going directly to Prolog and Haskell is not a bad idea but you might have to first adjust to the different syntax and libraries of the languages when compared to the leap between C# and F#. Personally, I went from C#/Java to Haskell by means of 2 books: RealWorldHaskell and The Craft of Functional Programming, and managed fine, so there is no reason for you not to be able to do so. :)

  3. Learning F# and then Haskell still requires some work because F# and Haskell are different: the first is "impure" while the second is "pure". Impurity means that certain "side-effects" such as state and IO are intrinsically allowed, while purity means that you don't get them immediately but have to use certain methods (such as monads). Coming from C# it would be perhaps easier to try F# and then Haskell cause of this.

  4. I believe (personal opinion warning), that if you want to become a better C# programmer, learning about F# and Haskell (or anything for that matter) can never hurt! Especially in the case of F# which can be integrated with C#. Functional programming may facilitate certain things for you and knowing it might become useful sooner or later especially since it seems, like the others said, that there is a current trend towards functional language programs.

Andrew Calleja