Catch up on stories from the past week (and beyond) at the Slashdot story archive


Forgot your password?

An Interview With F# Creator Don Syme 267

OCatenac passes along an interview with Don Syme, chief designer of F#, which is Microsoft Research's offering for functional programming on the .Net platform. Like Scala, which we discussed last fall, F# aims at being an optimal blend of functional and object-oriented languages. "[Q] What is the best program you've seen written in F#? [A] I've mentioned the samples from F# for Scientists, which are very compelling... For commercial impact then the uses of F# in the finance industry have been very convincing, but probably nothing beats the uses of F# to implement statistical machine learning algorithms as part of the Bing advertisement delivery machinery. ... We've recently really focused on ensuring that programming in F# is simple and intuitive. For example, I greatly enjoyed working with a high-school student who learned F#. After a few days she was accurately modifying a solar system simulator, despite the fact she'd never programmed before. You really learn a lot by watching a student at that stage."
This discussion has been archived. No new comments can be posted.

An Interview With F# Creator Don Syme

Comments Filter:
  • by serps ( 517783 ) on Sunday February 07, 2010 @04:02AM (#31050998) Homepage

    According to wikipedia (yeah, I know, I know), FORTRAN is "a general-purpose, procedural, imperative programming language that is especially suited to numeric computation and scientific computing. []".

    F#, on the other hand, is a "multi-paradigm programming language [...] that encompasses functional programming as well as imperative object-oriented programming disciplines. []"

    In summary, FORTRAN is for Formula Translation, I guess? F# is Functional, but with language support for OO or C-style programming.

    I admit I know bugger all about Fortran, but I suspect it doesn't have the full functional programming support that, say, Haskell boasts. At any rate, even if it did, it's likely that the last 50 years have advanced the field of programming sufficiently to make a new language worthwhile. So if you're up for functional programming on the .NET platform, F# is a great addition.

  • .NET Framework (Score:5, Interesting)

    by Yuioup ( 452151 ) on Sunday February 07, 2010 @04:26AM (#31051062)

    Last year I wanted to know what all the hoopla was about functional programming. I checked out Haskell, Scala, OCaML and F#. Coming from a Java/Delphi/C# background myself I had to go through it a couple of times before I "got" it. I'm glad I did because I banged out my first production IronPython lambda function on last Friday (yay!).

    I know that MS bashing is popular here on Slashdot, but I really want to take a moment to say that the .NET Framework really is excellent. The ability to mix and match different paradigms and languages in a clean an concise manner which is a joy to program in.

    Yeah I know patents bla bla mono bla bla Novell bla bla Miguel bla bla.

  • The optimal blend... (Score:3, Interesting)

    by mandelbr0t ( 1015855 ) on Sunday February 07, 2010 @04:32AM (#31051076) Journal
    ...of object-oriented and functional programming languages would be one without any functional perspective. I've learned both, I've managed both, and OO didn't drive me insane. Functional-based programming languages are syntactically inferior to OO ones, just as natural languages have features that make some more primitive than others.
  • by Ethanol-fueled ( 1125189 ) * on Sunday February 07, 2010 @04:37AM (#31051086) Homepage Journal
    You forgot "paradigm" []. My last shop was a C# shop. Never ceased to amaze me how the programs would prompt for the model number and freeze, then crash and and require a manual(Windows ctrl+alt+delete, of course) process kill before the operator had to enter the model number again.

    The impression given to the layman is that Microsoft technologies continue to enable idiocy. Hell, the code I dealt with at Java on Oracle shops was slow as fuck but at least it worked the first time around.
  • by Mr. Freeman ( 933986 ) on Sunday February 07, 2010 @04:51AM (#31051120)
    Dunno why exactly this was modded all the way down to -1, he has a good point.

    A child "modifying a program" isn't very spectacular. Any moron with no experience can modify "hello world" to spit out "goodbye world". I'm quite certain that "modifying a solar system simulation" went something along the lines of this:

    Problem 1:
    Part A) Replace the values in the program with the proper values for the orbit of the planets. // This is the time it takes jupiter to revolve around the sun (in earth days)
    int orbit_of_jupiter = 0; // This is the same as above, but for earth.
    int orbit_of_earth = 0;

    void main()
    lots of programming that is NEVER looked at or touched by the student;

    Part B)
    Record your results in the Excel spreadsheet and email it to the teacher. Then print out a copy and hand it in because the teacher isn't quite smart enough to open attachments in outlook.

    I mean, seriously people. When you hear claims of "High school child modifying amazingly complicated programs that take years of know how to write correctly", think about it for a little bit. If it sounds too good to be true then it probably is. If F# were this amazing new language that allowed anyone with no experience to write any program, we'd have heard about it one hell of a long time ago.
  • It is, kind of (Score:3, Interesting)

    by _merlin ( 160982 ) on Sunday February 07, 2010 @05:20AM (#31051176) Homepage Journal

    FORTRAN has dug itself into a corner where it survives quite nicely. It's used for mathematical, engineering and scientific libraries. FORTRAN just seems to lend itself to expressing these sorts of problems better. Mind you, the whole program probably won't be written in FORTRAN - any UI code and other glue will be written in C. F# is filling the same niche for .NET - the mathematical and analytic libraries are being written in F# while C# is used for UIs and other glue. So even if it's a completely different paradigm, in spirit it's the FORTRAN of the CLR.

  • by shutdown -p now ( 807394 ) on Sunday February 07, 2010 @05:22AM (#31051182) Journal

    being Microsoft it will probably not run on 95% of our compute clusters

    F# specifically supports Mono on Linux and OS X. I somehow doubt it's good enough for clusters, though...

    In any case, I don't think that's the intended use case. It's not for computationally intensive stuff - you'd still want Fortran or C/C++ there, as you've rightly noted - but for the kind of computations that you do on your own box. These guys [] provide some supplement tools.

    That said, it can still be used to massively parallelized, scalable tasks, since it has some stock parallelization primitives, and can also use .NET Parallel Framework (which is task/taskgroup-based automatic scheduler on lower level, and automatic parallelization of queries and transforms over sequences on higher level).

    Therefore... Why should I care? What does F# do, for me as a scientist, that I should invest my time into it?

    Do you, as a scientist, use Haskell or ML? If so, you can think of F# as the same kind of thing, but with first-class IDE and debugging support, and ability to quickly throw together UI frontends in WPF (it's pretty good for rather advanced visualization).

  • by shutdown -p now ( 807394 ) on Sunday February 07, 2010 @05:28AM (#31051196) Journal

    Functional-based programming languages are syntactically inferior to OO ones

    Most likely just the ones that you've seen, and for the tasks you've thrown at them. I wouldn't write a line-of-business application in F#, sure, but I wouldn't write a parser in C# either.

    While we're at syntax - I've yet to see any non-hybrid OO language which has anything matching the power and beauty of classic FP pattern-patching. For any sort of tree processing especially, it's a god send - whereas in OO you have to deal with ugly visitor pattern hack.

    Then also, FP doesn't have to mean "alien syntax", either. Have you seen Scala? It has everything any self-respecting FP language needs to have, yet it's still very much OO-centric, and the syntax is broadly Javaesque.

    To conclude... one of the first two OO languages, and the one to which pretty much all OO languages today owe at least half of their design, is Smalltalk. Coincidentally, it's also a very potent FP language - blocks are nothing but first-class functions, and they were used so pervasively in the language and the standard library that even the most basic conditional statement was actually a method call with two blocks...

    And yet, Smalltalk is considered as one of the most pure OO languages ever.

    Which is to say that OO and FP is really orthogonal, and not at all contradictive. You can have both, and either one is good for something different - so there's no reason not to have both, and get the best of both worlds.

  • by MichaelSmith ( 789609 ) on Sunday February 07, 2010 @06:01AM (#31051308) Homepage Journal

    Okay everytime this kind of article comes up on slashdot people point to five or six other languages I have never heard of. Now smalltalk is an old language and I have heard of it and you make some good points about what it can do. So why do we have so many unique languages? Is it because people want to start from a clean slate? Surely working on virtual machines and calling standards is just as important.

  • Re:C++ original? (Score:3, Interesting)

    by shutdown -p now ( 807394 ) on Sunday February 07, 2010 @06:03AM (#31051324) Journal

    Well, C++ templates are unique. I don't know any other language that has a macro facility that pretends to be a generic type system... ~

    Anyway, C++ was not original from language design perspective - it does indeed rip off Simula a lot - but who actually wrote anything in Simula? It was a very niche language, while C++ became mainstream. Most people who used it first saw all those Simula features in C++, and don't really know better. So "according to many developers", the assertion may even be correct...

    It's very similar to how a lot of Java coders genuinely believe that Java was the one to pioneer OOP, and haven't even heard of Smalltalk, much less Simula.

  • by otter42 ( 190544 ) on Sunday February 07, 2010 @06:16AM (#31051356) Homepage Journal

    I'm going to say something anathema to the /. crowd, but I'm looking into it with interest for replacing Python. I first teethed on FORTRAN, moved to Matlab 10 years lates, and have been using C extensively for the past 2 years. I'm starting into Python as a quick and dirty replacement for Matlab, and am quickly falling into a love-hate relationship with it.

    The love comes from all the cool things that Python can do, for free. Dynamic typing, .append() functionality, etc. It's just awesome.

    The hate comes from the sheer lunacy that is Python syntax. Forced whitespacing doesn't suit my debugging style (why not just have the compiler recognize either whitespace or accolades?); functions names like len() are just, frankly, idiotic (length() is much more readable to beginners, and takes only a few extra milliseconds to type for experienced users); and the way of working with indices is just weird (2:5 means the 2nd, 3rd, and 4th elements, but not the fifth; range(2 5) gives you 2 3 4, but not 5.).

    Python reminds me of many of these incredibly powerful scientific projects that never got used by a non-scientist until it was far too late to make changes. range() is a good example of this, as while it perfectly emulates "for i=2; i < 5; i++", it is NOT what you expect to get when you say, outloud, "I want a range of numbers from 2 to 5". Having contributed to Scilab, I should know as I'm equally guilty of this kind of thing.

    If F# can fill this void, by giving functional programming with functional syntax, I'll probably stop my Python experiments and move directly to F#.

    Although to be honest, I'd love to find a python front end that uses non-insane syntax and then simply precompiles it into python syntax at run-time. Then you don't have the MS, Windows, and .Net ickiness.

    P.S. I'm not looking to start a flame war about force whitespacing. There are really good reasons to like it. All my programs have consistent whitespacing, except when I debug (I like to put debug programming all the way against the margin, that way there's no possibility of ever forgetting it in the code)). However, you can't have it both ways on readability vis-à-vis function names and indices.

  • by shutdown -p now ( 807394 ) on Sunday February 07, 2010 @06:26AM (#31051384) Journal

    The love comes from all the cool things that Python can do, for free. Dynamic typing, .append() functionality, etc. It's just awesome.

    You do realize there's no dynamic typing in F#, right? It's very rigidly typed, in fact, more so than C/C#/Java - it won't let you use an int where a float is expected! (it's the price you have to pay for type inference - it doesn't play well with ambiguity)

    The hate comes from the sheer lunacy that is Python syntax. Forced whitespacing doesn't suit my debugging style

    F# is indentation-driven by default, much like Python (actually, more like Haskell, with more subtle rules). You can turn that off, technically, and use explicit semicolons - but that is considered legacy mode, and the community at large shuns it.

    functions names like len() are just, frankly, idiotic (length() is much more readable to beginners, and takes only a few extra milliseconds to type for experienced users)

    FP languages traditionally have terse names - how about the classic foldl and foldr ("fold left" and "fold right")? F# mostly follows suite - the most recent version is a tad more verbose, but you'll still be dealing with things such as Seq.mapi [].

    Although to be honest, I'd love to find a python front end that uses non-insane syntax and then simply precompiles it into python syntax at run-time.

    On the whole, it looks like what you're looking for is actually called Ruby.

  • by El Cabri ( 13930 ) on Sunday February 07, 2010 @07:45AM (#31051656) Journal

    ...of a functional language, it is simply Microsoft's offering of a functional language. The former statement sounds like it's one of the dozens of functional languages fostered in academia, for academia to play with. The whole difference here is that, as of Visual Studio 2010, F# becomes a fully productized and supported language in the .NET world. That's really what's exciting for functional language geeks, because never before a real, modern functional language of the generation built in academia in the 90s, like OCaml and Haskell, had such a mainstream backing.

  • Re:.NET Framework (Score:3, Interesting)

    by fredrik70 ( 161208 ) on Sunday February 07, 2010 @08:11AM (#31051758) Homepage

    If you like ironpython, check out Boo ( statically typed (or dynamic if you like) language which has borrowed most of the best features from from python.

  • by selven ( 1556643 ) on Sunday February 07, 2010 @08:18AM (#31051780)
    I agree that Python has some strange things about it, but look at some sample f# syntax from Wikipedia:

    let rec factorial n =
        match n with
        | 0I -> 1I
        | _ -> n * factorial (n - 1I)

    What do those funny characters mean? What's the I after the numbers? Compare to the python one liner:

    def factorial(n): return 1 if n == 0 else n * factorial (n-1)

    That makes sense even to someone with absolutely zero experience in the language.
  • by chico_the_chihuahua ( 925601 ) on Sunday February 07, 2010 @08:53AM (#31051874)

    Your example includes some distractions like bigint literals (0I and 1I), and uses pattern matching, which doesn't exist in Python.

    You have to learn the language to be effective, the wikipedia article was showing the F#-onic way of writing it - it's perfectly possible to rewrite this in a more imperative form as:

    let rec factorial n = if n=0I then 1I else n*factorial (n-1I)

    but pattern matching is a key part of the language. The compiler can detect whether all possible pattern states have been caught, which it can't do with if/then/else statements.

  • by Anonymous Coward on Sunday February 07, 2010 @09:56AM (#31052092)

    The majority of opensource projects I see on sourceforge are buggy pieces of shit. There must be something about OSS that attracts too many people who do not have what it takes to be a great programmer.

  • by johnlcallaway ( 165670 ) on Sunday February 07, 2010 @11:27AM (#31052558)
    Advanced??? Changed maybe. 30 years ago I taught myself BASIC from reference manuals in a few hours, enough to write a quadratic equation graphing program for my calculus class for extra credit. My second program was a password cracker so I could get higher priority on the university computer. I've modified code in languages that I had no experience in without any manual just by looking at syntax. So someone taking a few days to learn a programming language and modifying a planet simulator isn't all that impressive for a language ... they just found someone that learns quickly. I'm impressed in the person that picked it up, not the language. It mostly comes down to understanding if/then/else logic, loop constructs, and how to call methods after you learn syntax. Learning these constructs isn't too difficult, applying them takes a little more.

    So now .. instead of spending a few days learning syntax, and a few months mastering a language, we now take a few days to learn syntax, and YEARS to learn all the calls and libraries that go along with it. My first attempt at C++ resulted in my giving up, not because I didn't understand the language but because I was trying to write GUI programs and didn't have the right book to explain which libraries to use and why.

    Programming tools have definitely advanced. The days of punched cards and line editors like EDLIN are far gone for most programming needs. It's nice that modern languages don't let you overflow arrays anymore or have to deal with pointers.

    The biggest advances in programming??? Compilers, recursion, and object oriented syntax. I've seen far too many 'the next big thing' to get excited over something like this. Remember when C# was supposed to be the next big thing???

    But I'm still using the same if/then/else and loop logic that I did 30 years ago. No matter how much things change, they still stay the same....
  • by Ornedan ( 1093745 ) on Sunday February 07, 2010 @12:06PM (#31052738)

    One can write a Haskell version of factorial that looks pretty much the same as the F# version:

    factorial :: Num a => a -> a
    factorial n =
      case n of
        0 -> 1
        _ -> n * factorial (n - 1)

    This contains similar pattern matching expression, even using the same match-anything-pattern-keyword '_' and some additional polymorphism syntax in the type signature. The type signature could be left out and what's shown is what the compiler would then automatically derive.

  • by msclrhd ( 1211086 ) on Sunday February 07, 2010 @12:58PM (#31052988)

    So F# is for scientists and the finance industry, yet it cannot run on most mainframes (GNU/Linux or Unix), but there is mono that can, but does not work for computationally intensive applications.

    That means that it will not be able to be used for Quantum Mechanical calculations or General Relativity calculations or any other calculation that scientists would like to perform. Nor would it scale to the large amount of real-time transactions that a bank or stock trading company would need to perform.

    So how is F# better than Fortran & C/C++?

  • by Anonymous Coward on Sunday February 07, 2010 @09:01PM (#31056572)

    Purity essentially defines "functional" as a programming paradigm. Purity allows programs to be reasoned about in terms of "term languages" of recursive structures. Haskell's list data structure is isomorphic to the type:

    data List a = EmptyList | Cons a (List a)

    A list is either empty, or it is a an "a" attached to a list of "a"s via Cons. There are two cases. And only two cases. Functions on lists only have to handle these cases. How would we concatenate lists?

    (++) :: List a -> List a -> List a
    EmptyList ++ right = right
    left ++ EmptyList = left
    (Cons h t) ++ right = Cons h (t ++ right) --

    The last night reads "The concatenation of (Cons h t) (whose head is h and tail is t) and another list is the Cons of h and the concatenation of the tail t and the right List."

    Notice that in addition to being simple brief, the code also happens to be true. This code is basically a proof that Lists form a "monoid" -- an algebraic structure with an "additive" operation. This abstraction so common that it has been abstracted into the Monoid type class:

    class Monoid m where mappend :: m a -> m a -> m a

    For any data type for which you can prove is a monoid, you can create an "instance declaration" for the Monoid type class, and gain the benefit of all theorems proved about Monoids (all functions defined in the Monoid type class). This is somewhat similar to OO inheritance, but a little different. Classes and subclasses -- which can be defined with the => ("implies") operator -- share a relationship of logical necessity, and is not suitable for ad hoc polymorphism. To get that, you simply create a new type, and declare it an instance of your type class. You can even create a wrapper around an instance, and create a new instance for the wrapper, emulating ad hoc polymorphism quite nicely.

    data Rainbow = Red | Orange | Yellow | Green | Blue | Indigo | Violet
    class Rainbow obj where color :: obj -> Rainbow

    instance Color Rainbow where color = id

    newtype WebSafe = WebSafe Rainbow
    instance Color WebSafe where
            color (WebSafe Red) = Blue -- The tricky bit ;-)
            color (WebSafe c) = c

    A key consequence of purity is programmatic monadism. Evaluating a program always amounts to evaluating a function for a state, either by some internal representation of state as in Haskell's State monad, or by some support environment like Haskell's IO monad or Scheme's REPL loop (or init. Or the kernel. Or the processor. It's turtles, sequencing everything above them, all the way down). But this monadism also implies that evaluating a function amounts to joining properly typed data structures (because the function must work for any state). Indeed, this ought to be obvious. A function is isomorphic to a subset of the cartesian product of two types, with some constraints. A function is clearly a "join" of some kind. As the relational algebra people have been saying for years, joining data is complicated by not using the normal forms for data. A functional programming language supports simple normal forms for complex recursive data structures, and makes writing "joins" on these structures simple.

If it's not in the computer, it doesn't exist.