sorry if this has already been answered but the other posts on this are out of date.
I want to build a Windows 8 app in HTML5 and JavaScript that uses an F# portable library project to do the computational heavy lifting. Is this allowed? When I tried to add a reference to my F# project from the JS project VS2012 gave me an error but then let me add it anyway, will this blow up in my face later? I also want to make a Windows Phone 8 version
Thanks
As far as I know, the current F# compiler cannot create a WINMD component (mentioned by Denis) so you won't be able to call F# code directly from JavaScript. It might be possible (but I'm not sure!) to create an F# library as a portable library and reference it from a C# project compiled as WINMD component and then reference that from JavaScript. This adds an additional step, so it might be a bit inconvenient.
Please submit this as a feedback on the Visual Studio UserVoice. It is more likely to be added if more people vote clearly say that this is an important scenario for them!
Alternatively, as mentioned by Ramon, there are tools that translate F# to JavaScript and would allow you to run your F# code as JavaScript (and call it directly from JS):
I only have experience with FunScript (which works pretty well and has some nice features), but WebSharper has been around for longer, so I suppose it is more solid. It also adds more sophisticated GUI framework based on formlets (and similar patterns) while FunScript simply provides type-safe access to JQuery via a type provider that imports TypeScript definitions.
JavaScript metro apps can not call .net libraries directly. To make it possible for javascript to call your F# library you should turn it into windows runtime component (winmd). Now, I am not 100% sure if it is possible to make winmd using F#, since officially microsoft only supports c# and VB. On WP8 side javascript can not call .net or winmd libraries directly, so you would have to bridge js and .net manually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With