Functional Programming Has Reached The Masses; It's Called Visual Basic

In May I will be speaking at Expo-C in the beautiful town of Karlskrona, an official UN World Heritage Site. It is great to see that all the buzz around LINQ is putting functional programming back in the picture and the organizers have asked me to combine a Haskell tutorial with an overview of LINQ, including C# 3.0 and Visual Basic 9.(*) in addition to my "coming out" talk VB IsNot C#.

This, and the ICFP deadline last Friday have prompted me to write a short memoir of my journey to democratize distributed data-intensive dynamic applications by leveraging the great ides from functional programming. Comments, supplementary information, missing related work, and flames are all most welcome. In particular I am interested to learn if anyone is using H/Direct to use Haskell for programming against XPCOM.

Hope to see you in Sweden, or at any of my other gigs.

(*) I will be using Graham Hutton's excellent slides.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

extension properties

Read your paper, in which you reference the paper "First-class relationships in an object-oriented language" by Gavin Bierman and Alisdair Wren.

Seems to me that with Linq, almost everything is in place for implementing their first-class relationship concept. Extesnion properties would be one very nice part of an implementation.

Extension properties were mentioned a lot around the time of the first Linq preview - any chance we will see them added into the next preview release?

typo

On page two, there is the statement:
"A phantom type is a parameterized type whole type parameter is not used in its RHS."
I think there is at least one word missing in that statement?

There are quite a few other errors here and there throughout the document... interesting stuff though.

Missing word

Page 5, section 4, paragraph 3, sentence 2: Two word "between" is missing.

Sec. 6, par. 2: "goad" -> "good"

Similarly...

...2.2.4, "XMLambda was (a) still born experiment"; 2.3, "An interesting time to inject Haskell as (a|the) new hot client-side scripting language."

provocative, as always, Mr.

provocative, as always, Mr. Banana... :)

Typos in examples

The BookCompare examples on page 7 and 8 contain in the Select part PriceA instead of APrice.

flames

As far as I can make out, VB.Net has one thing in its favour: syntax support for optional late binding / dynamic typing. Late binding in vanilla C# is a bit of a pain: you have to say things like obj.GetType().InvokeMember("memberName", System.Reflection.BindingFlags.InvokeMethod, null, obj, object[] {param1, param2});. All the same, it's possible; and AFAIK VB.Net's late bound obj.methodName(param1, param2) compiles to just the same bytecode.

It's nice of the VB.Net compiler to distinguish between early and late bound calls in this way, and to generate the late bound calling code for you, but I don't think it's an earth-shattering advantage over C#. If it's so useful, why not just teach the C# compiler to perform the same trick? (Or do what Boo does, and have objects declared as "duck"...).

It also has special syntax for LINQ

So it's now a mainly procedural language with some object-oriented programming bolted on one side and monadic functional programming bolted on the other.

Years later, exactly that happened

If it's so useful, why not just teach the C# compiler to perform the same trick? (Or do what Boo does, and have objects declared as "duck"...)

That was a good plan, and exists now in C# 4. It's really nice when you need it.

... it has reached the masses before, and it was called Excel

Any spreadsheet is a non-recursive first-order functional program.
From this point of view, functional programming is the by far most
widely used programming paradigm :)

...in A-normal form, anyway

It's maddeningly difficult to build compound expressions in Excel. I've found you have to put just about every intermediate result in a separate cell. It's like programming in A-normal form. :)

Spreadsheet extensions

It's interesting that people intending to extend the spreadsheet paradigm have been ambitious in their extensions. I think a big improvement could be made with two seemingly straightforward extensions:

* support for compound expressions (ie "let x = ... in ... x ...")
* support for first class constructed values (probably records and arrays).

FRP

Once you're at that point, it seems like it would be simpler to add a spreadsheet-esque UI over an FRP framework (e.g. Cells for CL, Yampa for Haskell) than to tack on Real PL Features on top of your typical macro language. Heck, do it with AJAX or Comet or some other Web 2.0 magic word and you could even get financing ;)

FWIW, I believe gnumeric and scheme-in-a-grid both expose Guile bindings.

FRP

I agree in principle. It's just that when I'm frustrated at the limitations of conventional spreadsheets, it seemts that not much would be required to gain alot of utility. See also Vital and Pivotal which look promising, but release slowly, and are not open source.

yampa and spread sheets?

Perhaps you could expand on your comment about GUI+yampa being more powerful than standard spread sheets?

I never really understood this FRP stuff but it looks like some sort of data flow framework...so far I see the relation to spread sheets. But how might end user functionality be increased if spread sheets were a combination of FRP and grid UI?

The worlds most popular functional language...

Amusingly, that paper also

Amusingly, that paper also came from Microsoft Research...

Lotus Improv -> Quantrix Modeler

I'll just update the Classic archive by saying that Lotus Improv is now reborn as Quantrix Modeler; not open source, but very very nice. The Improv style is to take the equations out from under the cells, using them only for data entry and display, and allow fairly arbitrary array expressions as well. Furthermore, Quantrix models can have up to 12 dimensions with meaningful labels, and there's a clever UI for displaying the dimensions as nested rows/columns/pages; this is available not only in the app itself but also in the dynamic HTML it can generate.

Non-disclaimer: not affiliated with Quantrix except as a happy user.

Expression trees

I think this is one of the more interesting aspects of this work, and I suggest extending this section. I think it would be worthwhile to mention the work in Perl6 on macros, staged programming (Taha's papers), and partial evaluation.

extensible records

Hi Erik,

In section 4.1 you claim that "extensible records and record subtyping is still an open research problem". What are the research problems you're referring to? The subtyping rules seem straight-forward to me. I'm sure I'm just missing something.

Or did you mean inference for extensible records?

ICFP 2006

Expo-C was a great event; hopefully I will be able to participate agian next year!

My paper was a solid rejection from ICFP. I am not sure what to do next with it as I guess it will not be received any different at other serious conferences and I believe that ICFP is the most relevant venue to tell the FP community about the effect they have on the real world.

On the other hand, maybe an interactive and open forum like this is the best place to dissiminate ideas. The real revolution happens on the street not in the palace. In any case, thanks everyone for the comments and the great discussion. Keep an eye on my homepage for updated versions on the paper.