« Best Office View in the World| Main | A Good Cause »

Is F-Sharp Enough?

| | Comments (1)
F-Sharp Logo
Ready for prime time?

I've gotten the functional programming bug lately. Most of my career after I learned my third language or so, I could care less what the language is -- just let's solve it already, ok? But lately I've been hearing the functional programming wonks go on, quite at length, over how great functional and meta-programming is compare to common, pedestrian programming.

I'm not drinking the cool-aid yet, but what the heck -- let's fire up Microsoft's new F-Sharp language and take a quick look under the hood.

First pick up your copy of F# from Microsoft Research. Then fire up the old Visual Studio and take a look around.

Screen shot of visual studio with f-sharp web site loaded up
We're not in Kansas anymore

First, I'd like to say that this is one of the most butt-ugly things I've seen in a long while. I'm just a functional programming noob, but I know enough to know that trying to cram F# into an event-driven, 5000-class Microsoft libraries and the freaking complex-like-brain-surgery HTTP .NET pipeline is just nuts.

So color me unimpressed. I mean, the whole idea for functional programming, as I understand it, is to create just the tokens and functions that your new "language" needs for execution. Mixing it a huge hunk of imperative coding and extraneous junk is not getting with the program.

But then I ran across this cool blog entry by Thomas Petricek. Tom is writing an Ajax framework using F#. So why do we need yet another Ajax framework? Because of how he's doing it -- the right way.

His idea is that you have one page, sitting on the server, where you just write everything you want the page to do in F#, whether it's happening on the server or on the client. Want to write some server-side code? Tag it one way. Want to write some client-side code? Tag it another way. Want some things visible in both worlds? Then tag it! The library converts the F# dynamically into just the right amount of Javascript your page needs to have downloaded to the client.

This is one of the coolest things I've seen in a while. Here's a sample screen shot:

Screen shot of code sample
Okay. I'm impressed

Since F# is a superset of Ocaml, picture this scenario: you write simple, scripted web pages returning simple, lightweight pages to the client containing only the functionality your application needs. Then if you want linux, deploy on Mono. If you want to ditch the cumbersome and mostly unused ASP.NET libraries, switch to Ocaml and write a few libraries. You can develop on Windows, Mono, and n*nix, all in the same codebase and cross-compile.

Totally sweet.

In fact, Microsoft is doing this right now. Digging around some, I found mention of "several projects" that are using the cross-compiler and cross-machine capabilities of F#. One of the reasons this works is because F# is a Meta-Language -- that means you control the horizontal and you control the vertical. Okay already -- I'm getting the point of Meta-Languages. I could take this scenario above and spin off some awesome architectures on all kinds of hardware and software.

What I worry about is that blog entries like mine will cause some folks at Microsoft to go nuts. I can hear it now. Get rid of the ASP.NET foundational code! Heavens no! Not use all of that FCL stuff we've spent hundreds of millions developing? Perish the thought! We're going to have to find those F# guys at sit down and have a little talk with them!

Microsoft, after all, is one huge integration machine. The entire corporate structure is built up around integrating various products all into one, big, honking Microsoft nirvana. So having an F# language that is as pure as possible is not in their best interests. Just thinking of F#'s future is enough to make a body reticent about using it in production.

And there's a lot of Ocaml that F# does not implement yet, so there's still a HUGE question mark around whether this thing is going to fly or not. But in general, I'm intrigued enough to learn more and write some sample web applications. I am nowhere near recommending it to anything more serious than "hello world" Good luck, F# team! If you can make this new language 95% compatible with OCaml (It's not there yet enough to sell it that way, sorry) and complete the items on your to-do list over on the Wiki, I'll be your number one fan. Sell out to Microsoft's larger integration pressures and marketing strategies -- come up with something that's just functional enough for Microsoft to spin it to corporate America but not the real deal -- and I'll not be so kind.

1 Comment

This was a nice blog post about F#. By and large, once of the most attractive things about F# is that it compiles down to IL and you therefore can easily make use of all the .NET libraries. That said, having access to ALL the .NET libraries can be a nightmare. It's just too much.

I looked at F# about 6 months ago and seriously considered making that my next language. I passed on it because I feel I need to learn functional programming, but not through MS technology. I chose Python instead and I'm glad.

As to the ASP.NET framework. Ugh. It's great in that it is incredibly powerful. When you just want to quickly build something, it sucks.

Leave a comment

About this Entry

This page contains a single entry by Daniel published on October 27, 2007 2:48 PM.

Best Office View in the World was the previous entry in this blog.

A Good Cause is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.23-en
Daniel Markham