Jonatan Pettersson wrote:What's the pro's of functional language programming? The course I took in it left me kinda undecided, seems they're pretty good at recursion and that should be good when programming chess.
Anything else?
I'm too busy to write much about the topic right now, so I will just point you to the
Wikipedia page on functional programming. As everything on Wikipedia, it should be taken with a grain of salt, but after skimming through the functional programming article I didn't notice any glaring mistakes or omissions.
Andrew Fan wrote:Most functional languages uses lists or sets, their main strength is in backtracking and solving problems that cannot be described in algorithmatic fashions.
E.g. In (micro)Prolog you can ask questions like "Who are Mary's cousins" by just giving (enough) information about Mary's family tree, without specifying the direct relationship between Mary and her cousins - you need to define cousins though.
So may be the ultimate goal is to be able to ask the computer "What is the best move here?" and get an answer
You are confusing functional programming languages with logic programming languages, which are not the same. Prolog is a logic programming language. The most well-known functional programming languages are probably ML and Haskell.
For chess programs in functional languages, I have seen numerous simple toy programs, but never anything resembling a serious, competitive program. For efficiency reasons, I don't think a pure functional approach is likely to work well in computer chess. If we can't destructively modify the board data structure, we will have to do too much expensive copying during the search. This doesn't necessarily imply that a strong chess program cannot be written in a functional language, but only that not all parts of the program would be written in a functional style. I think it would be possible to write a strong chess program in an impure functional language like ML, although I am not sufficiently fluent in ML to do it myself. One of the countless things I would like to do some day is to write a serious chess program in Common Lisp, but it will probably mostly use imperative rather than functional techniques (contrary to popular belief, Common Lisp isn't really a functional language, but a multi-paradigm language).
Learning at least one functional programming language is well worth the effort, even if you will never use it for any serious task. It gives you a new way of thinking about programming, and can sometimes help you find original and elegant solutions to problems you encounter when programming in main-stream imperative or object-oriented languages.
Most programmers probably never see anything else than main-stream languages like Pascal, C, C++, Java, Perl and C#. I think this is a great pity. Being at least superficially familiar with the whole plethora of programming paradigms is very rewarding. A nice set of languages to study would be Haskell, Prolog, Common Lisp and SmallTalk. This is just my selection; I am sure it would be possible to come up with other, equally good selections.
Tord