Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any tools that assist in porting F# to OCaml?

Unfortunately, due to .NET's lack of an incremental GC (either in the MS or Mono implementation), building soft real-time software such as games with F# is problematic. I've written a language in F# that, if -

a) it doesn't perform adequately in the face of the generational GC (arbitrary pauses during the interactive simulation, and b) OCaml gets a good complete port to the LLVM backend -

I will port it from F# to OCaml. I have avoided as much .NET-specific libraries as I could, and since F#'s syntax is based on OCaml's, I'm assuming there should be some automated tools to assist in converting the code.

Anyone know of such things, either finished or in progress?

Thanks deeply!

like image 965
Bryan Edds Avatar asked Dec 16 '22 22:12

Bryan Edds


1 Answers

To answer your question in an answer - as far as I know, there are no such tools and I do not think it is likely somebody will create them.

Although F# is inspired by OCaml, it has evolved a lot and is different in a number of ways (see this SO discussion), so automatic conversion is not trivial. Even if somebody did that, it would be more like compilation to hard to read OCaml than conversion to idiomatic code that you can later continue working on.

To add a few general comments, when you speak about "real-time" I imagine controlling some robot in a factory dealing with dangerous stuff or an airplane control. In these areas, concerns about GC are certainly valid. However, I do not think games are necessarily "real-time". You need good performance, that's for sure, but people have been writing games with .NET and F# quite happily. For some F# examples, see:

  • ... a nice blog with a couple of game samples (that you can actually try & buy)
  • a 3D airplane shooter game that also looks fairly realistic
  • and there is also a book that uses games to explain F#

These are probably simpler than what you're aiming for, but it may be good enough to show that writing games using GC is doable.

like image 161
Tomas Petricek Avatar answered Dec 30 '22 21:12

Tomas Petricek