Is anybody aware of a possibility to use C# libraries like OpenTK (http://www.opentk.com/) from F#, too?
I'm especially interested in a Math toolkit library to give some scripts extra speed by taking advantage of the GPU from within F#.
What's a painless way to do that? :)
As Juliet mentions, you can use any .NET library from F#. Talking about OpenTK specifically, there is some material written by Laurent Le Brun (however, all of them are about graphics and not math):
An introductory article: F# + OpenGL: a cross-platform sample
More examples are in the samples/opengl directory in the F# cross platform project on CodePlex
It's probably not exactly the same thing as you're looking for, but it should help (e.g. if there are some tricky things that need to be done when using OpenTK from F#)
Related
Are there any good refactoring tools for F#?
I did some searching on Google, but there doesn't seem to be any available.
Am I missing anything?
Take a look at the new F# Power Tools Extension (Github). It provides a bunch of useful features for refactoring F# code, and it's gaining new features rapidly. If you there's a feature you want which isn't available, open an issue on Github about it.
There's been a Rename refactoring added to F# Power Tools very recently. You can find by searching for f# power tools in Tools|Extensions and Updates in VS 2012+. (See #Jack P's answer for more on that)
CodeRush templates and some select items such as duplicate line etc. work in F# but it's going to take lots of positive pressure to get much more (starting with not stealing Ctrl-Alt-F for invoking FSI).
JetBrains have a spike called FSharper but no stated concrete plans.
I usually use F# for writing numerical algorithms. Functional programming constructs in F# helps to express algorithms in a very natural way. I often end up with a succinct and understandable implementation, and may be able to parallelize it quite fast if there is a chance of parallelism.
I wonder there is a way to compile F# programs down to FPGA. In this way, I can still use F# to avoid boilerplate codes in FPGA programming, and make use of high performance computing in FPGA. Is this possible to do so? If yes, could you provide some hints for me to start with?
I've read about (but never used) Avalda's F# to FPGA conversion, but their site is currently returning a completely blank page. I don't know if that's just temporary of if it means they've gone belly-up.
F# should be ideal for this task because it is derived from the ML family of languages that were bred for metaprogramming. However, I am not aware of any work in this area (although I have had the idea of working on it myself).
I would focus on writing a compiler in F# that compiled a DSL to an FPGA, rather than trying to compile general F# code.
Here's a list for HLS tools using C. My experience with one of them in 2006 was not favourable but I expect them to be much better today.
Regarding F#, I doubt this will exist any time soon.
I'm currently creating a roguelike game and have already started coding in C# but have not coded much (<1000 lines) so far...
Now again, I have had a look at F# and this language seems to be very cool...I'm considering now using F# for the game engine, which, I think, will be 90% of the codeline (A roguelike has a very 'lean' ASCII-UI).
Do you think, F# would be better suited than C# concerning writing coding for procedural content generation, complex AI and game logic? Do you see any traps (apart from that I have to master the language first, of course)?
I've some concerns if F# is not just a research project and will be abandoned by Microsoft or are there statements that it is now a major .NET language?
Thanks for your input.
I don't see any traps.
F# fully supports .NET and even though it's mainly a functional languague you can implement the OO paradigma without a problem.
Also interop with C# is very well possible, so you could even go back to C# without giving up your F# code.
And as for it's future :
It's now part of VS as a stable language, so it's going very much in the direction of being one of the main .NET languages together with VB and C#.
F# is now a full MS product, and functional programming will be increasingly important in the future, so I wouldn't worry about MS losing interest in it any time soon.
F# should be a great choice here. I suspect you'll have some interesting state machines and I've found F# to be particularly good for that.
Good day all,
I am developing a small hobby project in OCaml. I was wondering how easy it would be to migrate it to F#. I know that F# has some features that OCaml doesn't, but I was hoping that my OCaml code would require little effort to port. I don't necessarily want to migrate, I want to retain / develop on both platforms.
Thanks in advance,
Michael
Writing cross-compiling code looks like a world of pain to me. John Whitington of Coherent PDF is the only person I know of who has tried to do this to any real degree.
I have translated a lot of OCaml code to F# (probably more than anyone else in the world) and the main problems are #light syntax, the use of any non-trivial OCaml features (objects, polymorphic variants, higher-order modules, labelled and optional arguments and so on), libraries (e.g. lablgl, lablgtk, ocamlgraph, laziness), macros (parsing, streams, pattern matching extensions) and changes in basic syntax such as array indexing. For example, I just tried to port the Almabench benchmark from OCaml to F# and it took several hours because I ended up by having to rewrite every a.[i] to an a.(i) by hand due to a multitude of bugs in the F# compiler: its OCaml compatibility mode is quite fragile.
So I would advise you to choose between the languages rather than trying to cross-compile.
You should read the final portion of the spec
Features for ML Compatibility
and be sure to grab FSharp.PowerPack.Compatibility.dll from the PowerPack for various compat libraries.
I haven't done any OCaml to F#-porting, but I know F# has been designed with OCaml compatibility in mind. As I know, F# is mostly a superset of basic OCaml.
It should support (and without #light be limited to) most OCaml keywords and have equivalents of most standard functions in the core libraries (or in the .Net framework). So I'd guess that - at least for hobby projects - porting should be actually easy.
F# doesn't have OCaml's advanced module system though, so you'll have trouble with implementing e.g. functors.
I'm writing a program in ocaml using ocamlgraph and wondering if I am to port it to F# what are my options ? Thanks.
QuickGraph is one of the most complete graph libraries for .Net
OCamlGraph is a beautiful example of a higher-order module system really paying off. F# cannot express this so a translation will not only be difficult to do at all but the result will be inherently far more cumbersome to use. Your best bet is to reuse some existing graph library for .NET and you'll probably have to settle for far less abstraction.
There is GLEE by Microsoft Research (it's an early version of Microsoft Automatic Graph Layout ). GLEE is free to download (MSAG must be purchased). I'm have used GLEE for large enough graphs. It's fast and easy to use.