views:

366

answers:

3

Hi.

Excel is a great spreadsheet software, a even greater front UI for Business Intelligence in many companies. Often VBA is used to write the extensions, or to call other DLLs.

As Excel itself is functional, F# will company Excel very well to write data analysis procedures.

I am thinking whether F# or a variant of F# will become next VBA in office. Any news or rumors?

EDIT: I don't mean to replace VBA in office. I mean F# could be an alternative in Office to write scripts.

+4  A: 

MS is offering VSTO, a bridge between every .NET language and MS Office. I do not think they will be favouring F# over any other .NET language for this task.

Doc Brown
+1  A: 

If you meant using F# for Office interop, you might want to try the dynamic lookup operator "?", but I think I'd prefer C#'s dynamic.

If you meant writing math functions for Excel, then yes, F# is a good tool for that. In fact here's a rewrite of Excel's financial functions in F#. You could write your own functions in F# and then use VBA to call them from Excel.

Mauricio Scheffer
good point! I am actually thinking whether MS will use F# as another VBA in office product as F# can be used as a script language...
Yin Zhu
+2  A: 

I don't think F# is a likely candidate to be the "next" VBA. Let's look at two major ways VBA is used in Excel:

1) Writing user-defined functions

2) Automating spreadsheet manipulation

I think (2) is much more common than (1). That's mostly imperative work using the Excel object model, and doesn't play to the functional strengths of F#. That's not to say F# or other languages wouldn't be just fine for scritping imperative spreadsheet operations, but VBA is also fine for that, and (just like its BASIC ancestor) is targeted at less experienced programmers. VBA was (and is) very important to the success of Excel, precisely because it made "end-user programming" relatively easy for people who were more end-users than they were programmers.

As others have pointed out, (1) can readily be done in F# right now, albeit in the form of a library, not tightly integrated with Excel. I myself would kill for a real functional language that was more tightly integrated with the sheet itself. However, I don't think it should look like F# per se. The real win would be the ability to express functions in a very Excel-formula-like syntax, and use them as first-class values in the spreadsheet. Lately a colleague and I have been building some models that are quite complex, but must be built and delivered in Excel. We've experimented along those lines, and it seems to be useful to us, but our implementation is definitely pretty clunky.

jtolle