Wednesday, September 21, 2011

Create a Metro App in F# (NOT) (Portable Libraries part 1)


update January 24, 2013: you are now able to create “Metro apps”: Windows Store Apps with F# (part 1) : Make things as simple as possible, but not simpler.


Today you can follow the all-F# approach (Build MVVM Applications in F#). This is not the easiest way to build a solution, it is not the preferred way, but it is an option.
Don Syme presented last Friday in his build talk the following slide.
FSharpMetro
When he explained this it was not completely clear to me what this meant.
Does this tell us that we cannot create a F# Metro front-end today but we will when F# 3.0 is ready? Or does this mean that you cannot create a F# 3.0 project and reference it from a C# or a VB Metro front-end app in one solution?
Today I watched some other presentations of day 4 of build:
Windows Runtime internals: understanding "Hello World" by Matt Merry
Being pragmatic by leveraging existing code in Metro style apps by Jason Olson
A .NET developer's view of Windows 8 app development by Krzysztof Cwalina
Ten Tips When Writing a Hybrid Language Metro style Application by Brent Rector
Using the Windows Runtime from C# and Visual Basic by  Harry Pierson and Jesse Kaplan
and experimented with Visual Studio 11 (Developer Preview and Express for Windows Developer Preview).
It became clear to me that you cannot create a Metro style solution that references a project that references .NET dll's that are not part of the .NET Profile for Metro style apps.
requirements
profile
The F# dll is one of them today. So creating a Metro app in C#/VB/C++/JavaScript that references a F# project is not possible.
This should be possible when F# 3.0 becomes available. Will it be possible to create an all-F# Metro app in the F# 3.0 time frame? For me, this is still an unanswered question.
WinRt
Another consequence of this approach: when you intend to reuse your .NET dll's you have to recompile your code as WinMD files. So you need to own the source code. WinMD
This are the restrictions:
Restrictions
Update(September 21, 2011):
Jason_Olson

3 comments:

Ryan said...

This is really unfortunate. What this messaging tells me is that I'll never use F# for any purpose other than hobby programming. :( I'll never convince anyone at any place I've worked at to use a niche language for niche purposes, even if it's a perfect fit. It's a maintainability argument that, while not really accurate, persists.

Donna Malayeri said...

Piet,

I'm Donna Malayeri, the program manager of Visual Studio F#, and I'd like to clarify some points in your post:

(a) The Developer Preview does not contain support for F# portable, as explicitly noted by the slides at //build/.

(b) Portable libraries will be referenceable from a C#/VB Metro project, including Add Reference.

Piet Amersfoort said...

Hi Donna Malayeri,

Thanks for your comment and clarification.

I intended to build a small application using the Metro UI and referencing an F# library I created in the past. After the watching the F# //build/ presentation it was not clear to me whether this scenario was supported. My confusion was caused by my lack of knowledge of WinRT and the definition of “portable libraries”.
I understand the implications of building a Metro more clearly after watching the mentioned WinRT presentations. Because you cannot reference legacy libraries I could have called this blog post “Create a Metro App using Open XML SDK 2.0 (NOT)”.

I have created follow up post: http://ps-a.blogspot.com/2011/09/reuse-of-legacy-by-winrt-and-metro.html.

I still have one question. I understand that Visual Studio will not support F# Metro front end apps in the same way Visual Studio does not support building F# WPF applications. Will it be possible to build and deploy F# Metro front end apps without VS tool support?

Total Pageviews