
Ask HN: What do you think of F#? - kia
Looks pretty succinct and expressive. Good IDE (VS) and nice framework (.net). Easy async programming, units of measure, quotations (as far as I understand it's similar to lisp macros). Though running on linux is pretty painful, it still can be done using mono.<p>So what do you think?
======
gaius
I love it. The classic problem of the niche languages, in this case the ML
family, has always been the lack of commercially relevant libraries. Which is
understandable, the strongholds of OCaml, Haskell, ML etc have traditionally
been academia. The other problem is that organizations have been reluctant to
start projects in languages for which it has been, rightly or wrongly,
perceived that there is poor liquidity in the job market, regardless of the
inherent advantages of those languages.

Both those problems have been solved in one fell swoop. Not only is the entire
.NET ecosystem available, but it's a shipping, fully supported part of Visual
Studio 2010. There is no reason _not_ to use it, from the organization's
perspective. Finally, all the FP programmers who've been hiding in the closet,
hacking in Haskell on their personal projects, can come out! These are great
days!

~~~
jrockway
Follow-up question: which libraries do you find most useful?

~~~
pella
"WebSharper"

<http://www.intellifactory.com/products/wsp/Home.aspx>

\---- example:

"This sample builds upon the formlet sample illustrating how _formlets_ may be
converted into flowlets for expressing sequences of web forms."

[http://www.intellifactory.com/products/wsp/samples/Flowlet.a...](http://www.intellifactory.com/products/wsp/samples/Flowlet.aspx)

~~~
smhinsey
I hadn't heard of this, but it looks really interesting. Do you have any
experiences with it you can share?

------
icco
I used it in a computational finance class about a year ago. I develop solely
on Linux, and although it was painful to get working, it definitely wasn't the
worst thing I have had to do on Linux...

The actual language was weird. Apparently it was inspired by OCaml, but I felt
it was far more verbose 90% of the time, and then randomly succinct. F#'s
error messages were straight up useless.

If you are looking for a good functional language, I would probably look
elsewhere, but it does have the advantage that it is currently still being
worked on, and it has all of the benefits that the CLR brings.

At the very least, I agree with the other comment that it will probably bring
more people into functional programming, which is always a good thing.

~~~
Dn_Ab
A genuinely curious question with the subtext that I do not agree with you but
wish to find out where you form your basis. The core languages of both are
nearly identical (ignore active patterns, computation expressions, .net libs
f# functors, polymorphic variants ocaml etc). You can port basic ocaml and F#
code and only have to change letters here and there.

What are your parameters for a Good functional language?

~~~
icco
Well, I would specify a good functional language as one I enjoy coding in. So
far that has been SML/NJ and Racket (PLT Scheme). For some reason I did not
enjoy F#, and I blame that more on the strangeness of the .Net libraries than
the syntax of the language. Also it has been a year, so maybe the language has
changed / I don't entirely remember all of the problems I had.

------
darklajid
I've used it for some pet projects, mostly to get my head around a functional
language with an easy entry (and exit) route for me: I'm a C# guy by day.

I started doing the Euler things etc. and did a quick dive into lexing/parsing
(one strong point that your list is missing, imo). I got hooked. While I still
cannot use F# for most of my things (technically it would even be possible,
but try to convince your higher-ups that it is a good idea to switch to a
language that they've never heard about, "because it is fun"), I use it for
small things on a regular basis. You can mix functional and
structural/iterative style (which is a plus in my book, the latter just _is_
faster if your program really wants to lend itself to mutable loops in
places). You have a huge and well-tested library - the interaction with
everything .Net is trivial.

Deployment isn't a big issue anymore: In the past you needed to either compile
it statically or ship the F# stuff as well, with its status as a "first class
citizen" in .Net 4 there's really no reason to back away from it anymore. It's
here to stay.

I didn't have any trouble running it on mono/linux - but I've to admit that I
last tried it quite a while ago.

Full Disclosure: I'm a kind of a fanboy here, I guess. The wall in my back is
painted with a very nice/succinct 13 line prime number generator in F#,
roughly 4cm line height, done as a decoration by my so.. ;)

~~~
peregrine
\--but try to convince your higher-ups that it is a good idea to switch to a
language that they've never heard about, "because it is fun")

I've never had issues convincing management the biggest issue I have is
convincing coworkers who don't see value in learning new languages.

~~~
gaius
That's the beauty of it - F# is now a peer of C# and VB.NET. There's no reason
whatsoever for organizations to shy away from it - it's mainstream now.
Whereas even tho' it's a very similar language, I can understand why a PHB
would balk at OCaml.

~~~
tl
It's an anecdote but I've had 2 PHBs that wouldn't accept C# in a "VB.NET"
environment.

~~~
gaius
Just look 'em right in the eye and say "dot Net". Works every time.

------
DanielBMarkham
I've been using it regularly for over a year, and I love it. I could start out
imperative and then code more and more in a functional style as I got to be a
better functional programmer.

Having said that, I did find the transition painful. But that's going to be
true of transitioning to FP no matter how you do it.

I'm still in a Windows environment, but I look forward to transitioning to
Mono once I get FP down. At that point I'll be on an open, free stack,
programming in a powerful language with tons of libraries and thousands of
people to help if I have problems. What's there not to like?

~~~
pufuwozu
I have to point out that F# is licensed under the Microsoft Research Shared
Source License Agreement, which isn't an approved OSI license.

[http://research.microsoft.com/en-
us/um/people/antr/vrr/vrr/l...](http://research.microsoft.com/en-
us/um/people/antr/vrr/vrr/license.htm)

They had plans to change to a MS-PL (OSI approved) license but still hasn't
happened after 2 years.

On a more practical side, the current license isn't bad, just obscure.

~~~
jdh30
F# was just released under to OSI-approved Apache open source license.

------
natch
This is a bit of an off-topic rant, so feel free to skip it if you would
prefer a direct answer to the question.

For many years I've made it a point to studiously ignore languages that come
out of Microsoft, having been burned too many times by their constantly
shifting and sometimes suddenly-expensive tools. Before anyone mentions price,
sometimes the expense is hidden in places like what system I would have to
run, with what total cost of ownership, in order to use their stuff. There may
have been some unknown opportunity costs to me, but I am blissfully unaware of
these and have had plenty of other fun languages to use.

~~~
gaius
F# is free.
[http://www.microsoft.com/downloads/en/details.aspx?FamilyID=...](http://www.microsoft.com/downloads/en/details.aspx?FamilyID=f8c623ae-
aef6-4a06-a185-05f59be47d67&displaylang=en) . You only pay if you need the
fancy "enterprise" features.

~~~
gcampbell
I didn't see a Visual F# Express there - does Visual C# Express include
IntelliSense for F#?

~~~
gaius
Download the VS 2010 redistributable shell and then the F# MSI.

~~~
tomasp
See also <http://fsxplat.codeplex.com>, which is a project with the aim to
make F# a better tool for cross-platform development. I'm currently working on
an (open source) MonoDevelop integration for F# (sources are already there),
but an announcement is yet to come...

------
loumf
At Atalasoft, we decided to make F# an allowed language for development (in
addition to C/C++, C++/CLI, and C#). We make imaging toolkits for .NET. There
aren't many downsides compared to C# -- it's totally interoperable with our
code, can be used to implement OO interfaces quite well, and it has some nice
advantages (terser syntax, inlining, asynch blocks, etc). The main downside is
in dealing with anything that uses Visual Studio Design support.

We don't use it for everything, but it has its place.

------
mhd
I just don't see a big enough advantage compared to its parent, Ocaml. Partly
because I wouldn't count Visual Studio and .net on the "pro" side. Ocaml is
basically the same language, you don't have a big methodology mismatch when
using libraries, it produces smaller executables that are quite fast, its
runtime has some advantages if I remember correctly. (And there's the
evangelist problem, but let's not get into that again.)

~~~
j_baker
F# is a somewhat simpler language than OCaml. Plus, it has decent concurrency
support (which is a bit of an issue for OCaml if I recall correctly).

~~~
mhd
Does F# have functor support by now? Because if that's what's meant by
simpler, I'd rather have a bit of complexity. If I program in a functional,
symbolic manner, I also don't want to kowtow to the runtime that just wasn't
made for such an use (If I recall correctly, Yaron Minsky of Jane Street
complained somewhat about F#'s allocation rate in this respect).

Concurrency is an issue that I hope the Ocaml developers will address a bit
more, though.

~~~
Dn_Ab
No functor support. Questionable if it would fit idiomatically with .net
framework culture but not something you miss.

In order of wish list to F#:

    
    
       - ability to create a structure isomorphic to GADTS
       - further enhancements to metaprogramming and how it does quasi quotation stuff
       - Support for Higher Kinds
    

The above would ameliorate the need for functors too, I feel.

------
vii
I've used F# at work.

It does have a sort-of REPL, you don't have to put one line functions inside a
dummy class, and the async monad and queues are pretty handy.

It doesn't benefit from adding yet another set of collection types to the .NET
API (which already has two semi-competing sets) but that is unfortunately
beneficial, partly due to the next point.

The balkanisation between the .NET typesystem (class at a time, overloading
ok) and the ML typesystem (sequential and no overloading) is a constant source
of irritation. How to make a short name alias to the System.Console.WriteLine
variadic function?

It's REPL unfortunately doesn't tie into the otherwise impressive VS
intellisense and is a pain to attach the debugger to.

It hasn't proper closures (you cannot mutate variables you close over).

It's not a coherent platform, but a mishmash.

------
nivertech
Check this Ocaml talk by Yaron Minsky from Jane Street Capital:
<http://news.ycombinator.com/item?id=1533275>

He said, that unlike Ocaml, in F# you still can get Null-pointer exceptions,
since it's based on .NET

~~~
ppog
That's partly correct. The danger comes not because F# is "based on" .NET but
because it can call into other .NET libraries. F# code by itself, including
the F# libraries, won't create null references except in two very specific
cases (see <http://msdn.microsoft.com/en-us/library/dd233197.aspx>). And F#
types are non-nullable unless you ask for them to be nullable.

But if you call into non-F# libraries, including .NET framework libraries,
then they _can_ return null references. And if your F# code tries to use a
null reference obtained in this way OO-style (e.g. making an instance method
call through the reference), then that will indeed cause a
NullReferenceException.

Obviously, it's easy to wrap 'dangerous' calls to return option values (F#'s
equivalent of Haskell Maybe) instead of nulls -- it's a judgment call as to
whether it's worth it for any given API.

------
passerby33
I used it for a while a few years ago. Like O'Caml or Haskel , F# is a
language that forces you think through your problem up front. For example you
must get your types exactly right before the program compiles. In return, you
get fewer runtime errors, e.g. fewer null pointer exceptions.

I stopped using it when I changed jobs and left the Windows platform.

I don't really miss F#. It was fun to learn and use, but wasn't helping me
write better programs quicker than C# or Python.

------
rlmw
I've been enjoying using it for both some personal and commercial projects.
Points I've noted myself that aren't really discussed so much in the usual
analysis, or maybe they're the 'small print':

1\. Active Patterns are incredibly useful. Active Patterns are the f#
equivalent of 'View Patterns' in Haskell. In other words they allow you write
a function that converts something into a pattern matchable form. The first
example I saw of this in Haskell was the ability to write a function of the
form:

dec (n + 1) = n

which performs the same function as:

dec n = n - 1

Whilst that 'cool' I didn't really see the applicability. Now you're in the f#
world and trying to interact with .net libraries its suddenly amazingly
powerful! Suppose you have a DOM api or something like that, that the
idiomatic functional approach would involve heavy pattern matching. Hey presto
- one simple function and you've wrapped up an imperative .net library and you
can think of it like a discriminated union.

2\. Multiple collections libraries are annoying. There's some functionally
oriented stuff in the f# libraries, but sometimes its a pain to get it to
interact with existing c# code - you might need to do some conversions. The
Seq module works over sequences - which are instances of IEnumerable - but you
find yourself looking at the LINQ extension methods, and the legacy c#
functions and then the f# ones and thinking 'its one platform - why are there
4 ways of doing something?'

3\. The f# compiler takes a while to generate code under Mono. I've not tried
mono 2.8 yet, but as of 2.6 it takes a significant amount of time to compile
projects. If you're compiling code in order to try and get a few errors, a
common thing to do if you're used to using your compiler to find bugs in your
code, then this becomes a bit of a productivity drag.

4\. Intellisense is still useful for functional programmers. I've noted a
propensity among advocates of self-described expressive languages to claim
that an IDE is a crutch for weaker programmers, or perhaps produce some other
ill conceived but dismissive response towards IDEs. In the past I've
considered the notion that the support something like Eclipse or IDEA gives to
Java programmers or Visual Studio gives to C# is something unnecessary in the
functional world. My mind on this matter has been changed by two things - one
being the Visual Studio support for f#. Its not as good as c#, but its at a
pretty young stage and is already highly useful. I feel a lot more productive
in visual studio than vim for example. The other aspect was my efforts in
teaching beginners to program haskell about a year ago. I was expecting a lot
of people to get stuck on Monads and combinators etc. What I didn't expect was
them to become confused on basic programming issues - things an IDE would help
them find solutions to more easily in a language like Java. So I'm inclined to
think from these experiences that IDEs are useful, even in a succint language
like f# and more importantly both to beginners and experts alike. (Assuming I
can consider myself an expert.) There's already a tool that provides the
intellisense support in an out-of-ide environment, and I hope that it will
mature soon enough that I'll be able to use it within vim.

I have a few more minor points - but I think thats all of interest for now.

~~~
ezyang
Slight bit of pedantry (not to detract from the overall content of your post):
dec (n + 1) is not a view pattern, it's an n+k pattern, and Haskellers have
mostly decided that they were a bad idea. However, you've gotten the point of
real view patterns (foo (someFunc -> x)) spot on: they encourage better data
abstraction, which is helpful if you've got an imperative .net library that
you want to interface with.

~~~
rlmw
Thanks for the correction. I admit I've not fiddled with Haskell's equivalents
to Active Patterns to any great extent - as since I mention in the original
comment I didn't hugely see the motivation in that context. I really only
mentioned them since I assumed more people would be familiar with haskell.

~~~
jdh30
Haskell doesn't have active patterns. Although they were originally proposed
for Haskell by Wadler, they don't make so much sense with non-strict
evaluation because you can just write code to compute the result and match
over it safe in the knowledge that it will be computed on-demand only as far
as required.

------
S_A_P
From what I have seen, it seems that MS is pushing this as a way to
parallelize a section of your application. Meaning that you would use c# for
most of the app and write a performance critical/parallel section in F# to
avoid using locks/ critical sections.

Maybe I'm seeing things wrong, but it seems that MS is not looking to make F#
as mainstream as c#.

~~~
Tangurena
F# is a bit weird to folks who are used to C# or VB, which is what PG was
referring to with the "Blub" paradox. F# is different enough that the majority
of .NET programmers I meet, or work with, have no frame of reference to
understand F# with. The only ones I know who code outside the office are
trying to get rich with iPhone or Android apps.

~~~
GFischer
I'm a "Blub" programmer, and yes, I really don't have any frame of reference
to understand F#.

And I'll probably try my hand at Ruby or Python before F# or Lisp... I've read
many posts and articles about how at least trying Lisp will make me a better
programmer but I still don't want to take the plunge.

I'm not a hardcore programmer (heck I'm starting an MBA next year (1) ), and
pretty pragmatic - if my tools help me build what I want, great. I don't
object to learning new tools but there's a significant time cost to that, so I
have to prioritize

(1) I've also read a lot of advice about why I don't want or need an MBA but
I'm trying to look at it like an entry point into the business world and a
networking and career advancement opportunity. I like solving problems outside
of programming (making better processes and such). I'm not a salesman or
marketer, but I am interested in business.

------
sahillavingia
I had no idea what it was. For those similarly unaware:
[http://research.microsoft.com/en-
us/um/cambridge/projects/fs...](http://research.microsoft.com/en-
us/um/cambridge/projects/fsharp/)

~~~
jefffoster
The big thing is that F# has graduated from MS Research and is now available
as Visual F#. This is important as it could make functional programming more
mainstream (or at least into the hands of more people).

------
MLnick
I'm curious as to what libraries are available for linear algebra and
numerical computation (free / open source ones) and how they compare to e.g.
Numpy, mpj or colt on java, etc?

------
fleitz
I love it. Pair it with a few C# projects to get all the LINQ-TO-SQL goodness
and ASP.NET MVC + nhaml and you've got yourself a beautiful way to develop for
the .NET platform.

------
mh415
Here's F# on OSX: <http://blog.mbharrington.org/2010/10/27/fsharp-on-osx/>

------
jdh30
I love it!

