tags:

views:

488

answers:

6

I'm a professor, and I was thinking about introducing a new language to the curriculum, and I was intrigued when my Visual Studio 10 (beta) came with F#...

After reading How will F# (sharp) be used? and What’s the benefits of using C# vs F# or F# vs c#? I feel that I possess the beginnings of an understanding as to what the purpose of F# is, and why it might be used over, say, C# or VB. But I'm still not convinced that it would be a good idea to try teaching it...

Can someone provide me with a good rundown of potential pros and cons for using F# as a teaching language?

A: 

I'm sure you have read this already, but here's the MS Research page on F#:

http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/

The obvious difference is that it's a functional language, based on ML, instead of an imperative one.

Mike Houston
+2  A: 

F# is sort of a Microsoft clone of OCaml. OCaml in turn is a flavor of ML, which is a functional language. So you can think of F# as a nice functional language created by Microsoft that runs on .NET.

If you don't currently have a functional language in your curriculum, you really should. I took a course that used Lisp when I was an undergrad, and found the experience mind-expanding. I was never afraid of recursion again. The whole experience was worth it for that alone.

T.E.D.
I've used F# on Mono on my Mac for some simple testing, and it seemed to work just as well as it does on Linux. Is there perception that F# on Mac (using Mono) is less usable than F# on Linux (using Mono)?
harms
Interesting. I didn't realise mono worked on Macs. Is that under MacOS, or does it require you replace the OS with Linux?
T.E.D.
T.E.D.: Mono is available for Linux, Mac, and Windows. I use Mono and the nice IDE MonoDevelop easily in OS X as well as Ubuntu, so no, you don't have to replace the OS to run Mono on a Mac.
Sarah Vessels
OK. Deleted the whole last sentence then, so as to not perpetuate my Mono ignorance. Thanks for the correction Sarah.
T.E.D.
+6  A: 

F# is a functional language based on OCaml, which itself is Objective Caml -- an Object Oriented version of Caml. Caml is a dialect of ML, an old, old functional language.

F# has clear advantages over OCaml, such as simplified syntax, strong concurrency support, and access to the whole .Net infrastructure as well as Visual Basic 2010 first-party support.

C# has shortened the gap quite a bit between it and functional languages, but F# will still drive circles around it with the right problem set.

There are good demonstrations of it on the web, which make clear how concise and business-rules-oriented it can be.

As for a professor, it is a functional language, with a long history, but strong commercial support. That should be enough.

Daniel
+1  A: 

After having done some Standard-ML while at university, I'm now learning F#. I understand that this may be subjective, but I find the syntax of F# highly convoluted compared to SML. Given F#, I think the new concepts of f.p. would be masked by the necessity of having to deal with the intricacies of F# syntax, giving more frustrated students learning less.

SML syntax is more familiar from plain mathematics and other programming languages, and one would be able to present the concepts of f.p. more easily.

But when f.p. has been learnt, understanding F# should be very easy, as the only real barrier then is the convoluted syntax.

harms
+3  A: 

I've used F# to coding examples and algorithms while teached 2nd year studens with C/Pascal background to database related algorithms (database engine, simple SQL parser, sorting, RB/.../ tree implementation, zippers, etc). Language very concise, so i had no problems to write examples on our interactive board and students demonstrated very good results on final exam. Now i wrinting advanced algorithms course for 4r year studens, but i plan to use some members of ML family (F#, JoCaml and OCaml) to show different views for reactive, async and concurent programming, lazy evaluation and symbolic computations.

There is nice article about comparing Objective Caml and Standard ML: link text

Here is my short list pros and cons for F# vs OCaml:

(+) ints with standard bit length
(+) fast BigInt arith
(+) arithm ops doesn't differ for any types
(+) range expressions for collections (lazy and eager)
(+) computation expressions (a la Haskell's monadic syntax)
(+) nice .net interop
(+) good COM interop
(+) no global interpreter lock
(+) light syntax version (a la Python)
(-) no structural typing (but there is "let inline")
(-) OOP part of language is not so nice (but authors to imrove it with each release)
(-) no functors (but for most cases they maybe emulated f.e. Set.Make)
(-) optional type members
(-) no labels
(-) no camlp4/5
(-) no nice OCaml infrastructure to install libriries and to compile projects
(-) smaller community
(-) exceptions costs much more ticks

Functors may be emulated by using generics and/or interface types:

type IStack<'a> =
  abstract pop: unit -> 'a
  abstract push: 'a -> unit

let stack (create: unit -> IStack<'a>) =
// ...
ssp
no polymorphic variants, as well. But could you expand why Set.make can handle situations where functors could be implemented? (I am assuming Set isn't implemented as a functor in F#).
nlucaroni
+1  A: 

I agree that learning any FP language is valuable, and SML is my choice for its simplicity, clarity, and power. It disproves the general premise of modern languages that power requires complexity in a language.

Learning the new FP paradigm is also useful, and helps students (anyone) to see that Imperative is not the only approach that is useful. FP concepts are becoming mainstream now in all languages (closures, lambda, currying, ...), including dynamic languages which are very popular and important.

What I like about F# is that it is Microsoft - which for students (and developers) give it credibility, and that it has a nice IDE. What I don't like for teaching is that the syntax is more cumbersome, and that IP features dominate the language. Pickering's book for example has 38 pages on FP features of F#, and then 56 on imperative & OO, out of a total of 350. Most of the rest is on .NET features, which are the real contribution of the language.

But current relevance and the Microsoft label help sell the topic to students, so it is a tradeoff!

Guthrie