Using F # Portable Library with HTML5 / Javascript on Windows 8 and Windows Phone 8

Sorry if this has already been answered, but other reports about this are outdated.

I want to create a Windows 8 application in HTML5 and JavaScript that uses the F # portable library project to do weightlifting. It is allowed? When I tried to add a link to my F # project from the JS VS2012 project, I gave me an error, but then let me add it anyway, will it explode on my face later? I also want to make a version of Windows Phone 8

thanks

+6
source share
2 answers

As far as I know, the current F # compiler cannot create the WINMD component (mentioned by Denis), so you cannot call F # code directly from JavaScript. Perhaps it is possible (but I'm not sure!) To create the F # library as a portable library and link to it from a C # project compiled as a WINMD component, and then reference it using JavaScript. This adds an extra step, so it can be a little inconvenient.

Please submit this as a review of Visual Studio UserVoice . This will most likely be added if more people vote, clearly say that this is an important scenario for them!

Alternatively, as mentioned in Ramon, there are tools that translate F # to JavaScript and allow you to run your F # code as JavaScript (and call it directly from JS):

  • WebSharper is a commercial, supported, open source product under the AGPL license.
  • FunScript is a recent open source community community available in Apache 2.0

I have experience with FunScript (which works very well and has some nice features), but WebSharper works longer, so I believe it is more durable. It also adds a more sophisticated GUI infrastructure based on formlets (and similar patterns), while FunScript simply provides secure access to jQuery through a type provider that imports TypeScript definitions.

+4
source

Metro JavaScript applications cannot directly access .net libraries. In order for javascript to call your F # library, you must include it in the Windows runtime component (winmd). Now I'm not 100% sure if winmd can be done using F #, since Microsoft officially only supports C # and VB. On the WP8 side, javascript cannot directly access .net or winmd libraries, so you have to manually bridge js and .net.

+4
source

All Articles