jeha
jeha

Reputation: 10720

Metro style Apps with F#?

In the Build 2011 keynote and demos, they were always talking about C++, C#, Visual Basic and JavaScript. Can't I build Metro style Apps with F#? Or is it safe to say that if it works with C#, then it works with F# as well?

Upvotes: 16

Views: 3863

Answers (6)

Masahiko Miyasaka
Masahiko Miyasaka

Reputation: 191

I ported my stock chart library for .NET3.5-4.0 to Portable library,it works quite well on Metro with C# Metro application and some my Metro UI bridge. I'm convinced that I can use F# to make Metro application in many parts.

Upvotes: 1

Martin Suchan
Martin Suchan

Reputation: 10620

The question has been answered here: Windows 8 and F# Although you cannot create and design Metro apps directly in F#, you can still create so called Portable library in F# with all Models and ViewModels and use it in another Metro projects. It's not ideal, but it works.

Upvotes: 1

jgraves
jgraves

Reputation: 487

Using Visual Studio 11 Developer Preview (Full, not Express), I was able to reference and run F# code from a C# Metro style application with the following caveats:

  • You will get a build warning saying that the project can't be referenced, even though Visual Studio will still allow you to add it.

  • You must remove all references to all DLL's in the F# project, including FSharp.Core.

By following these steps it is possible to run F# code from a C# Metro style application, but it is nearly impossible to write any useful code in F# without references to the core language libraries. Let's hope they update the libraries to be WinRT compatible soon.

Upvotes: 6

Piet Amersfoort
Piet Amersfoort

Reputation: 81

I had the same question and created a blog post: Create a Metro App in F# (NOT)

There are a few issues:

  • You cannot reference ordinary .NET dll’s (even in C#). They have to be have recompiled with a “reference” to the WinRT. Because of this you cannot reference the F# dll. I think this will be solved when F# 3.0 get released (source: Understanding F# slide from Don Syme at build).
  • The ability from F# to create Metro apps. This has to be built by the F# team. This is an open question. This is the all-F# approach (In WPF it is today possible but not recommended).
  • Tool support for creation Metro front-end projects. This will be not the case for the F# 3.0 release. (source: Understanding F# slide from Don Syme at build).

Upvotes: 8

Brian
Brian

Reputation: 118865

Don talks about this a little around 7:40 into his talk.

http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-904T

Upvotes: 11

Darin Dimitrov
Darin Dimitrov

Reputation: 1038810

Or is it eligible to say if it works with C# then it works with F# as well?

Yes, that's how it is supposed to work. In addition to javascript and C/C++, any CLS compliant language that runs on top of the CLR will have access to the WinRT API.

Unfortunately in the VS 2011 Express edition you don't get tooling support but I guess this will be added progressively or to other editions:

enter image description here

Upvotes: 12

Related Questions