F#, WebSharper, JavaScript, HTML5, Mobile etc.

I'm catching up on blogging about what's been going on in F# lately.

One thing that happened over the vacation is that the F# HTML5/Mobile development tool called WebSharper is now open source, and free for use for open source projects (details on the site). There is also a community project called Pit (also on github) which compiles F# to JavaScript, and which I'll write about separately. You can use these today in conjunction with F# 2.0 in Visual Studio 2010. With WebSharper there is ASP.NET integration as well, and add-ons to target extra web/HTML5/mobile functionality.

If you don't know about WebSharper, the website is here. The guys behind the project call WebSharper "the world's most versatile web and mobile development platform".

As we all know, there is a growing amount of activity in compiling languages to JavaScript, e.g. languages like Dart. Now, compiling-to-JavaScript is not functionality Microsoft include with F# 2.0 or 3.0. But personally I think its great to see the F# community compiling F# to JavaScript with both WebSharper and Pit. It seems like this is an area where the community will be really active.

And I can see why. When you do JavaScript/HTML5/mobile programming with F# as the development language, you get the usual F# goodness: strong typing, full intellisense, type inference, asynchrony, pattern matching, Visual Studio development, units of measure, ... and the power of a modern typed functional programming language. You also get the performance and functionality of .NET for the portion of your code that runs on the server side. No need to use NodeJS on the server to get a homogeneous language across client/server. And no need to wait for new languages.  Indeed, this is related to the research vision pursued by Tomas Petricek when he first got involved in F# back in 2006.

Furthermore, on the server-side you get the option of cloud integration, including the Azure technologies for ASP.NET, Hadoop on Azure and Cloud Numerics, and emerging tools like M-Brace. This gives homogeneous strongly-typed programming with a modern, high-productivity functional langauge, all the way from device to cloud, and encompassing the traditional enterprise along the way.

Equally, I can see the attraction of other techniques for the device UI, and that would be our normal recommendation for F# in the absence of WebSharper and Pit. HTML5 and JavaScript are themselves a great ecosystem. And you can use standard JavaScript/HTML5 (or CoffeeScript/HTML5) over F#-implemented services on the server-side. The F# MVP Dan Mohl has been tweeting and blogging about those possibilities a lot lately.

My personal belief is that JavaScript/HTML5 progrmaming will, over time, trend towards a range of languages which will support homogeneous client/server programming. JavaScript itself is and will remain huge. But it seems we're sure to continue to see typed languages that compile to both JavaScript and .NET/JVM/.... (GWT, Opa etc.)  If you look at these kinds of languages, it seems to me that F# is nicely set up to play well in this space over the long term. F# is a succinct modern language, and logically speaking the language is relatively independent of .NET. Also, perhaps somewhat surprisingly, F# translates quite nicely to JavaScript, and indeed is quite similar to JavaScript in its focus on things like functional-first programming and asynchrony.

So, is F# "just" a .NET language? If you ask the F# community, it encompasses HTML5 and JavaScript as well. And certainly F# is an ASP.NET and Cloud language, through .NET, and for my day-to-day work my focus is on compiling F# to .NET and other implementations of the CLI (well, I'm very much focused on the wonderful new features for F# 3.0 available in the Visual Studio 11 Developer Preview). But the community seem to be taking F# to JavaScript/HTML5, and indeed F# was very much designed with this kind of flexibility in mind.

In any case, I like the idea that a language like F# is a living thing and that the community are doing things along these lines. Through making and using these tools they are taking F# to important places.

Don