19

I would like to learn a functional programming language to see a different programming paradigm.

My background in programming: Java (I have just passed the SCJP exam), some ruby and very limited Rails. I use bash for basic sysadmin tasks. I use Ubuntu 9.04.

As a second goal I would like to use fp to show kids (14-18 years olds) how math and cs interrelated. The guys are very good at programing (they are learning Python and Java at politechnical high school from the first year). However as tests show, they have difficulties with math esp. basic concepts of discrete math. I think we can develop their math skills by using programming (and I possibly that can be the topic of my teacher training thesis). I think a language with very basic vocabulary would serve this project best.

txxwq
  • 753
  • 1
  • 7
  • 18
  • 1
    The top three (by number of votes) talk about four different languages. Which tells me why such a question is usually not so helpful. Also, since you know Ruby, which support fp to a certain extent, why not use it to further your understanding of the concepts? What I usually do when learning a new paradigm is pick a language, work on it for a while (2/3 days) and move on to another if I don't like it for whatever reason. And yes, I keep the option of revisiting it open. YMMV. – dirkgently Feb 01 '10 at 19:15
  • 1
    Compare with http://stackoverflow.com/questions/744368/which-functional-programming-language-should-i-use which has essentiall the same answers and also the related http://stackoverflow.com/questions/927272/what-is-the-best-functional-programming-language-for-experienced-oo-developers and http://stackoverflow.com/questions/1348896/what-is-the-best-functional-language-for-scientific-programming . I haven't voted to close yet, but I'm not sure that this is actually adding anything... – dmckee --- ex-moderator kitten Feb 01 '10 at 19:47
  • Yet another near-duplicate: http://stackoverflow.com/questions/779800 discusses half a dozen different functional languages from a newcomer's perspective; some people seem to have found it helpful. – Norman Ramsey Feb 02 '10 at 01:30
  • First of all sorry for repeating a question. I'll try to browse the questions more accurately before asking. I'd like to learn fp to see a new perspective and I'd like to use this new knowledge to improve my students. So let me clear my second concern: I'd like to link math to programming. The guys are good in programming but their math grades are lower. So i am thinking about possible solutions to use their interest in cs to explore math concepts. A brief list: naive set theory, concept of function, propositional logic, the concept of proof. – txxwq Feb 02 '10 at 07:00

9 Answers9

17

I vote for Haskell, which has the following advantages:

  • In Haskell, the simple case is actually simple
  • The complex case is (usually) still comprehensible by ordinary human minds
  • It has an ordinary syntax that's not too different from other non-functional programming languages (unlike, say, Lisp)
JSBձոգչ
  • 40,684
  • 18
  • 101
  • 169
  • 1
    I'd second and add that it has a [very good introductory book](http://book.realworldhaskell.org/). – Yoric Feb 01 '10 at 20:23
12

I'm a big fan of Scheme, not least because the best book on it is freely available.

Jon
  • 1,249
  • 1
  • 10
  • 21
  • 1
    SICP is not the best book on Scheme, Little Schemer nee Little Lisper is. – HandyGandy Feb 01 '10 at 20:20
  • Okay, let me revise my statement as saying one of the best books on it is freely available. And I have to pick up a copy of the Little Schemer. – Jon Feb 01 '10 at 20:44
10

If your primary goal is to work with teens, it makes sense to use the functional-language pedagogy and technology that is proven to work with teens, and that is PLT Scheme (aka DrScheme) with the How To Design Programs book (also free online). These guys have got great results from middle school through 3rd semester university. They have resources for teachers as well.

Many respondents like SICP. It is a wonderful book—but not to learn from. If you already know Scheme, it is a good book to admire, but SICP is less about functional programming and more about how to implement all known interesting computer-science ideas in Scheme.

If your primary goal is to learn a really new programming paradigm, then Scheme lacks some features that are very important to many functional programmers:

  • Programming with pattern matching
  • Partial application of curried functions
  • A polymorphic static type system
  • Pure functional computation

If you want exciting ideas, try Haskell; Haskell makes it a lot harder for you to program your old thoughts in the new language. Instead, Haskell forces you to think new thoughts. In addition to many other resources, Real World Haskell is free online.

Final note: SO has had many similar questions on learning functional programming.

Community
  • 1
  • 1
Norman Ramsey
  • 198,648
  • 61
  • 360
  • 533
8

Scala and Clojure both run the JVM so you might be more familiar with their environments.

CookieOfFortune
  • 13,836
  • 8
  • 42
  • 58
  • 2
    Given the already existing background in Java these are probably ideal choices. If he had Microsoft background I'd recommend F#. – Joel Etherton Feb 01 '10 at 19:10
7

I'd try Scala. It's not purely functional, it allows you to use a variety of approaches--but much of your java knowledge should port (It's JVM based) including the JDK libraries, and it's one of the most advanced languages I've ever seen.

If you're interested in learning language features and expanding your knowledge of how languages work, I couldn't imagine a better alternative.

Bill K
  • 62,186
  • 18
  • 105
  • 157
1

My vote goes to Scala or F#, which are both freely downloadable at the moment.

The advantage here is that they are mixed paradigm languages -- Natively they are functional languages, but you can also use imperative and Object Oriented programming. They also have large standard libraries -- Scala rides on the back of Java and F# has all of .NET, so you can program something interesting fairly quickly.

Scheme and Haskell are both pure functional languages, but unfortunately their standard libraries are relatively small, so it's hard-ish to do relatively common things, like parsing XML or scanning web pages.

Joel
  • 5,618
  • 1
  • 20
  • 19
0

Since you're already familiar with Python, why not just use its functional capabilities? For more, see this (draft) HowTo.

GreenMatt
  • 18,244
  • 7
  • 53
  • 79
  • Python's pretty lackluster as a functional language. Sure, it supports some common elements you expect to find in a functional language (closures, first-class functions, and even functions like `map`) but that doesn't make it a functional language. Functional programming is more about a *style* than specific language elements, and Python doesn't enforce (or really even encourage) a functional programming style. Also, if you're using Python to try to teach existing programmers functional programming, they're apt to just use the imperative aspects of Python as a shortcut anyway. – mipadi Feb 01 '10 at 19:27
  • The guys are familiar with Python, not me. But I will read its fp capabilities because I think that'd be easier to approach a new style with a known language. – txxwq Feb 02 '10 at 06:51
0

My question is what approach is likely to be best for the teens you're working with. If they're willing to learn something new and different, Scheme is an excellent choice as a functional language. It's as basic as they come. If you want to keep to a more familiar syntax, Haskell might be your answer.

David Thornley
  • 56,304
  • 9
  • 91
  • 158
0

If you are doing this for learning, then definitely Scheme with SICP. It's going to be hard and frustrating and will blow your mind if you don't have experience with this stuff, but you will learn a lot.

If you want to use functional programming in practice then F#, Scala and Clojure are worth looking at.

Jules
  • 6,318
  • 2
  • 29
  • 40