3
$\begingroup$

I learnt a lot (like kept hearing about it) about functional programming after coming to this community. I had heard of it before but was unaware of its importance. Then, I started including functional programming in my daily conversations with my students.

Now, a couple of students (who are already familiar with dot net) are asking me if I can teach them functional programming. Given that I am a dot net guy, my mentor suggested that I try F sharp.

The question is, is F sharp a good choice for learning functional programming? If not F sharp what are the alternatives.

Note : Any alternatives that you suggest must have full support on windows as well as Mac. For example, F sharp works just fine on Visual Studio for Windows and Visual Studio for Mac.

$\endgroup$
  • $\begingroup$ I think that Scala looks interesting and it builds on the JVM. $\endgroup$ – ncmathsadist Sep 15 '17 at 0:26
5
$\begingroup$

Actually, I think a better choice would be a true functional language (Scheme, ML, Haskell) rather than a multi-paradigm language.

Of course it depends on your goals. If you really want them to learn the functional programming mindset then don't use a language that lets them escape to other paradigms so easily. F# permits programming in many ways, including imperative and OOP. So, if they have a multi-paradigm language, you can either just let them program using what is available or you can try to enforce a style that may not be natural in the language. I think this would be frustrating - more frustrating than just pushing through the needed transition of thought.

However, in a true functional language you don't have the option of just "making it work" using thought patterns you have already developed when learning a different paradigm. The transition to functional can be difficult, but it isn't made easier by letting students not do it.

If you want them to run, don't let them crawl.

I'll note that I with a bit of a library I can program functionally in Java. But I wouldn't use that as a way to teach functional programming.

$\endgroup$
  • $\begingroup$ We simply do not have the luxury of pursuing something which does not have an endgame that has no industrial applications. For us, any time spent learning something is an investment and must have (monetary) returns. Would understanding Scheme, eventually lead us to using F sharp better? We understand that it will be challenging but we have already taken that into consideration. $\endgroup$ – Jay Sep 13 '17 at 14:08
  • 1
    $\begingroup$ Then you have other goals, of course, than teaching functional programming. $\endgroup$ – Buffy Sep 13 '17 at 14:11
  • $\begingroup$ That is true. Step 1 : Learn functional Programming with Language X Step 2 : Do something with it. Step 3 : Profits :P However, we are still in step 1, and we have to finalise on a functional programming first. If we need to start with Scheme, then we will do that, but I thought I will ask the experts here first since you folks talk about functional programming so much as it is. My own mentor is convinced that F sharp is awesome for functional programming but he has no option on other languages. $\endgroup$ – Jay Sep 13 '17 at 14:17
  • $\begingroup$ At the same time, while I got lucky with these 2 students, we are unable to convince other students to join us because they are asking us 'what is the end game if we learn'. So, if we can prove that functional programming has practical applications, we can get more students to participate next year, if not this year. $\endgroup$ – Jay Sep 13 '17 at 14:19
  • $\begingroup$ I assume your students have most experience with languages that use concrete syntax. A shorter step for them would be ML (OCAML) or Haskell, rather than Scheme. It would seem more familiar, but would require the change in mental processing. $\endgroup$ – Buffy Sep 13 '17 at 14:20
2
$\begingroup$

I agree with Buffy that, if the goal is to actually understand functional programming, using a true functional language makes more sense. Get rid of the temptation to move back into imperative programming, or the odds your students have of really understanding this new mindset diminish considerably.

You may want to take a look at the discussions over here. When I asked that question, I was unsure whether to use Haskell or Scheme, and the answers there (especially this one) ultimately led me to choose Scheme (DrRacket in particular). The idea of pedagogical sub-languages for distilling the key ideas was very persuasive. I think that this is a great way to get into functional programming.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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