An Interview With F# Creator Don Syme
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."
Will D flat be the same language as c#?
Obvious retort is why?
the solar system is a program of physics. a child understanding the program enough to alter a simulation of it makes the claim of the child having no programming experience quite questionable.
go tell someone else, marketing droid. F# stinks.
Sure, when everything works out. Something tells me F will mean something completely different when youre getting compiler errors or crashes.
and the emotive language and buzzwords
*yawn* unconvinced.
"[Q] What is the best program you've seen written in F#? [A] A bunch of generalized statements, as though I've never actually seen a program in this language."
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.
...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.
"Please describe the scientific nature of the 'whammy'" - Agent Scully
If someone makes a debugger or syntax checker for it, will it be called 'F#CK'?
Slashdot: Where opinions are just opinions until you have mod points.
If I want something done fast I code in python. When I want something fast done I code in C. They are perfect for what I need to do.
If you also know Java well, Groovy can also be an excellent tool, and is also useful in production environments.
"There is more worth loving than we have strength to love." - Brian Jay Stanley
As a longtime programmer in languages such as C++, Java, C# etc, and having explored many other dynamic and functional languages such as Perl, Python, Ruby, Haskell, and Lisp, I can honestly say that F# is now hands down my favorite language. There are a few reasons:
- it's like the best parts of all the paradigms rolled into one. Statically typed, but with automatic type inference to do most of the work for you. Fantastic generics - every function is generic without any of the scary syntax or mental overhead. First class functions, closures, all that good functional stuff. All the same objected oriented features you'd have in C#. All the garbage collection etc of the .NET platform. You can do things in almost any style you want and it never feels like you have to fight the language.
Of course, pick and choose your language, and you can find many of those features elsewhere. But here's the best part:
- it runs on .NET. You can use all of the .NET libraries, no need to hunt for and integrate third party libraries that are half implemented because of your wacky obscure language choice.
- you can sell it to your boss. Supported as an official MS product and included in Visual Studio 2010. Integrates flawlessly with C#. Has a great IDE already. Draw your WPF GUI in Expression Web if you feel like it and write the backend in F#.
Honestly I never want to go back. It's like that Paul Graham essay where he talks about how Lisp is so productive that his company killed the competition. Now I feel like every line of C#/C++ I write is a waste of my time.
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.
Hmm...Amazon says he consulted on the book. Wouldn't be a problem except the author is one of the most notorious trolls in the FP community! Way to go, Microsoft PR! Maybe you guys can hook Derek Smart up with someone in the games division?
There's one particular reason to look at F#, and that's FParsec. Parser combinators are just awesome, and don't get me wrong - I like the original Parsec, and Haskell in general! - but its IDE support is minimal, and debugging it is a pain.
With F#, you get the same awesome tool, but in an environment where you can actually use it for day-to-day jobs - write any parsing code as an F# library using FParsec, and call it from the main body of C#/VB/IronPython code.
Something tells me F will mean something completely different when youre getting compiler errors or crashes.
fgrep??
Totally marketing garbage. Man is probably a great guy, with a lousy job. But F#, really? even .NET is ripping off Java. Microsoft talks about building "ecosystems" but the way they do it, everything in the ecosystem has to have a M$ logo on it. Why can't they just inter-operate and integrate with outside software?
I had a sig, but
What if you need a complex program that's very reliable? I know it can be done in C and Python, but usually not without rigorous testing.
According to many developers, it is the most original new face in computer languages since Bjarne Stroustrup developed C++ in the early 1980's.
Ever used C, or Simula, or ADA. There is not a piece of originality within C++.
Then I stopped reading the article.
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.
www.eissq.com/BandP.html Ball and Plate System. Amuse your friends. Crush your enemies.
I understand that it is popular to bash anything that burst forth from the loins of Microsoft, but c'mon! This is Don, The Don, this is one hard-core damned brilliant programming dude (for want of a better term). He was single handedly responsible for generics in c# (something I am greatly thankful for in my day to day work) F# is his baby; the guy is passionate about the idea of a real world practical functional language. Sometimes people use emotive language when they are talking about things that they have devoted themselves to for years. Especially when they believe that it could bring functional programming into the mainstream. I have used F#, and personally really enjoy coding with it (and especially the different way in which solving problems in this manner makes you think). Might be a long time before it is excepted into production code though...
For those who don't have a clue but still have urge to comment, here is "hello world" in F#:
[start snipp]
#light
open System
printfn "Hello world\n"
Console.ReadKey(true)
[end snipp]
And another example illustrating what would would take a highschool kid to modify physics simulation:
[start snipp]
#light
open System
let gravity = -9.81
let euler_explicit accel pos speed delta =
pos + delta * speed, speed + delta * accel
let euler_implicit accel pos speed delta =
let speed2 = speed + delta * accel in
pos + delta * speed2, speed2
let pos, speed = euler_explicit gravity 0.0 0.0 1.0 in
printfn "pos = %f speed = %f\n" pos speed
let pos, speed = euler_implicit gravity 0.0 0.0 1.0 in
printfn "pos = %f speed = %f\n" pos speed
Console.ReadKey(true)
[end snipp]
(taken from http://sharp-gamedev.blogspot.com/2008_09_01_archive.html)
Cheers
nothing beats the uses of F# to implement statistical machine learning algorithms as part of the Bing advertisement delivery machinery
Are you SURE you want to promote that as a productive use of the language? Bring together two things that people love to hate? Even Google's ads are merely tolerated at best.
What's next, "F# for spammers"?
...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.
Don't you mean - yet more Vendor lock-in ..
WTF#
Looks like the languages are breeding. Look at the 'DNA' combining. Not Pretty. Lots of extinctions. If you can't stand the mess get out of the pool.
Aren't all the functional techniques in F# being pulled into C#? Like DryadLINQ, and other components from Microsoft?
--
make install -not war
If this is a functional language, it presumably makes generous use of recursion. Which brings up something I'd be interest in /. comments on...
There are a lot of algorithms that can best be expressed and (theoretically) most efficiently solved by recursion. However, (a) most programmers are not comfortable with recursion and (b) most programming languages (C++, C#, Java, etc.) make no optimization for recursion. In particular, they use a new stack frame for each recursion, even if the function is tail-recursive. This lack of optimization means that deeply recursive algorithms must be avoided - leading right back to (a).
My question for /. is simply: why? Why co modern OO languages not provide decent optimizations for recursion? Why are most programmers uncomfortable with it? What can be done to break this cycle?
Enjoy life! This is not a dress rehearsal.
I've never had a problem with python's whitespace parsing, but I read somewhere that python is so superior it has support for all the other schemes to denote blocks. For example, you can use 'begin' and 'end' keywords, you can also use braces {,} as well. Here's an example demonstrating python's superior syntax:
if foo == 3:
....block of code here....
....another block of code here....
#begin
#end
else:
#{
#}
You say you don't like 'len' as a name for a length function, that you would prefer using the name 'length'. Well, python is so superior, that you can fix that problem really fast in your code:
length = len
From your posting, you've got lots of experience number crunching. Have you taken a look at numpy and scipy? There optimized modules to give python the speed of fortran for doing linear algebra, statistics, etc. Want to do an svd,linear regression, sampling, etc. in python fast and easy? numpy is your best friend.
The one big showstopper I have with F# (which might (maybe) actually be an awesome language) is of course that it comes from Microsoft, who has a better proven history of screwing people and locking them into Windows than some Oil companies have of finding oil. On what platforms can I use this F# language? Please, no equivocating. I just want to be able to do: "sudo apt-get install F-sharp".
Why should I wrote code in a language that's bound to a platform/OS that's inferior to the one I use on a daily basis from a company who's trying to lock me into their products, when I have free easy access to code from people who don't have as an agenda screwing me over with their licenses, restrictions, treating me like a suspected criminal? If I want a functional programming language, I can run lisp, ocaml, haskell, ML, erlang, none of which restrict me as to which platform or OS I use.
Has this improved any? I really would like to used F# on Linux, but I will not go anywhere near something with licensing like this?
As one might expect, you can get moderated as Flamebait if you say the same thing about opensource as somebody said about .Net.
The funny thing is that the moderator missed the point. The AC was mocking the logic of the other poster, not really making a statement about OSS projects.
Q: What's wrong with C and Python?
A: They are great programming languages, but it is my observation that using them turns you into the sort of dickhead who believes that their opinions are intrinsically superior.
Begin-End
Stop it you are giving me pascal flashbacks.
Got Code?
Actually, that crashes because of crappy closed source software, specifically Adobe Flash.
Are you going to make F# available under an open source license like Apache, BSD, or LGPL? The current shared source license really makes F# unattractive for both commercial and academic use. Given how much F# builds on OCAML, it would also only seem fair if F# itself becamse open source.
You say you don't like 'len' as a name for a length function, that you would prefer using the name 'length'. Well, python is so superior, that you can fix that problem really fast in your code:
length = len
That *is* a neat feature.
My only beef is that it can't help to solve the mess that is everyone else's Python code. Once I'm programming in Python, all these things will seem very natural. (It can't be worse than C!) But for people who are new to Python, and just want to modify a tiny section of code in someone's script because it almost, but not quite, does what they want it to, all the myriad Python bizarreness jumps up and bites them.
www.eissq.com/BandP.html Ball and Plate System. Amuse your friends. Crush your enemies.
The problem is not that badly written programs fail. The problem is that even programs that were supposed to be well written in .NET crash miserably.
In the old days people would say "no one was ever fired for buying an IBM system". Well, there's at least one chief executive of a major corporation that has been fired for buying a .NET system.
It is impossible to combine a object oriented language with a functional language. Functional languages are about values. Values are closed. Values are the opposite of objects. Functional languages could only work on closed collections of objects as a whole, because such a collection would behave as an object. Any attempt to combine the two will lead to very strange and counter intuitive semantics where either one of the two has is seriously damaged. Either you get a functional language (working on collections of objects as a whole) or you get a object oriented language with non-functional semantics. Everybody who claims that functional and object oriented can be joined either does not understand what these words mean or have an alternative interprettation of what of either one of the two terms.
I'm aware of the difference, but even so, C programmers typically call them functions, not procedures, and I've been a C programmer for a lot longer than a functional programmer, so that's what I (and many imperative programmers) are accustomed to calling them. It isn't as if I don't think it's important to use words correctly, but I don't think it's productive to argue about who is using what word in the wrong way if my meaning is clear. If it isn't, then that's my mistake, then.
Syme disappeared.
Common Lisp is definitely both functional and object orientated.
How many times does it need to be said?
I have not seen one and I mean one .NET program that can simply be recompiled to run on Unix. There are always problems or something dumb like winforms not being up to 1.0 equivalent due to them using COM.
Novel Zenworks is the only thing that comes close because it has 2 different software versions due to the incompabilities of Mono. The linux version sucks very bad.
The whole reason why Google Sketch does not have a Linux port is because of .NET. Its nearly impossible to port it.
At any given bookstore how many books on .NET do you see that do not show Visual Studio and instructions on how to use it? Visual Studio and .NET seem to confuse programmers as the same product. ... in actuality they are. .NET is part of Microsoft's Visual Studio tools of Windows only development.
Let me know when paint.net can simply be recompiled with a checkbox to GNU/mono?
Its about as portable as C++ in my opinion in that you need the right apis on multiple platforms. This is why Java was created.
http://saveie6.com/
It is impossible to combine a object oriented language with a functional language.
You have to go tell OCaml authors that...
Functional languages are about values.
Not at all. I'm not sure what you mean by "values" here (I'll touch on that below), but the strict definition of a functional language is "a language that has functions as first-class values". That's all there is to it.
Values are closed. Values are the opposite of objects.
I think you need to provide your definition of "object" and "value" at this point. Are you referring to the fact that objects have inherent identity, while values do not? What about immutable objects, that are used solely for encapsulation and virtual dispatch (a la OCaml)? How are they any different from ADTs?
Or do you refer to immutability? It's not a hallmark of a functional language, either. For example, both Scheme and Standard ML have mutable values, but they're definitely functional. On the other hand, XQuery is pure - output is a strict function of input, no mutable state at all - but it doesn't have function types nor values, and so it's non-functional.
Everybody who claims that functional and object oriented can be joined either does not understand what these words mean or have an alternative interprettation of what of either one of the two terms.
"Alternative" relative to what? Yet again, you really need to provide your definitions for this to be comprehensible.
Not at all. I'm not sure what you mean by "values" here (I'll touch on that below), but the strict definition of a functional language is "a language that has functions as first-class values". That's all there is to it.
I would define a functional language a language in which all expressions (including defined functions) have no side effects.
Object oriented to me means the introduction of object identity. Object oriented languages often work with collections of objects, that have references between them. Of course it is possible to define a function that queries a collection of objects, but as soon as you introduces means to alter attributes of objects (including references between them) you get serious problems with definining the semantics of your language, because you are introducing side effects. Side effects have a profound implication on things like execution order, which in a purely functional language should not matter (think about lazy evaluation). The only way you can avoid these problems is to let all your functions work on the whole collection of objects. Which means that if you modify one attribute of an object, the whole collection of objects (closed over objects that reference each other) are modified, implying that all objects are modified that belong to that collection. When you reason like this way about a collection of objects, that collection of objects becomes a value.
But often when people talk about object oriented, that put the objects (and not the 'universe', the collection of objects that they belong to) at the center of their attention. For more of my thought, read the articles The Art of Programming and Object-Oriented Considered Harmful.
I've read (Russian) that the following code crashes in runtime:
let comp x y = x > y
let result = comp (new Dictionary<object, object>) (new Dictionary<object, object>)
(I am not an F# expert, I am a Haskell user;)
I would define a functional language a language in which all expressions (including defined functions) have no side effects.
I see. Well, this isn't the mainstream definition of "functional". What you defined is a "pure" (or "side-effect free") programming language, which, by the way, may or may not be functional. I already gave one example of such - XQuery, which fits your definition to the letter - no side effects whatsoever - but nonetheless it cannot be considered functional if only because it doesn't have first-class functions (no function types, no lambdas...).
Furthermore, Scheme and ML are widely considered functional, and they have mutability and side-effects.
Object oriented to me means the introduction of object identity.
Agreed, but the presence of identity does not imply mutability. It may sound surprising, but nonetheless - look at XQuery again. It does have node identity, which is essentially the same as object identity - some "magical" quantity that nodes possess quite aside from the aggregated value of their attributes and children - but you cannot ever mutate anything in a node. It also has lazy evaluation etc.
In what sense is the set of values for the function type "int -> int" closed? The set encompasses all possible computable integer-to-integer functions. That seems like a lot of values.
Indeed, it seems like exactly the same number of values as the number of objects with a base class with an abstract member taking an integer and returning an integer.
In other words, what is you definition of "closed?", particularly for function types?