So Mono is basically here, and with it comes C# support, and that's great by itself.
However, C# is not the only language that runs on top of the CLR - other languages such as F#, IronPython (Python on top of .NET), Boo (that one infamous scripting language that used to be in Unity), basically anything on this list that compiles to IL can run on Mono, and by extension in Godot.
However, right now it's not mentioned anywhere that this is possible, and it isn't entirely smooth of a process either to get F# et al to work in Godot projects (I haven't done this myself but I vaguely remember people talking about this being possible, though with limitations), and while I realize that there aren't infinite developers+money to go around and support every CLR language under the sun, I think it'd be at least worthwhile to mention how something like this can be achieved, since the Mono runtime is a really powerful thing and limiting it "just" to C# just feels like a bit of a missed opportunity.
But, maybe I'm completely wrong.
CC @neikeq
I've been writing generic F# libs for Xamarin monogame. It would be wonderful to be able to use those in godot.
F# is quickly becoming my favorite language, and would love to see support for it in Godot ๐
For whatever its worth, people are already asking about the possibility of a Clojure/Godot integration ๐
Clojure is my favorite language, but I've never used it on .net. Don't
know how good library and IDE support is.
On Nov 13, 2017 2:39 PM, "Ramsey Nasser" notifications@github.com wrote:
For whatever its worth, people are already asking
https://github.com/arcadia-unity/Arcadia/issues/258 about the
possibility of a Clojure/Godot integration ๐โ
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot/issues/12337#issuecomment-344083245,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAZ0ciJhjNICPSWnWslbU9byWDIWWa3iks5s2MUzgaJpZM4QCKDU
.
@NullConstant haha yeah working on it.
First step was getting a reference to the dll, by adding an itemgroup to the project.csproj
<ItemGroup>
<Reference Include="Clojure">
<HintPath>Clojure.dll</HintPath>
</Reference>
</ItemGroup>
I've put a working setup for Clojure at https://github.com/arcadia-unity/ArcadiaGodot
The plan is to rename CSharp* ScriptLanguage/Script/ScriptInstance implementations to Mono* and make them abstract classes. Language-specific implementations should derive from these (we would still only support C# officially).
The most basic implementation for a language-specific class shouldn't require too much. Probably extensions information only, like source file and project file extensions.
Now, regarding how to expose this API...
AFAIK, PluginScript only lets you implement classes that derive from Script/ScriptInstance/ScriptLanguage, so that won't work for us.
Exposing the API via C# has the penalty of adding a managed method invocation for the API methods the language implements. These methods aren't too much though, they are probably called only once (or could be cached) and we can use method thunks, so this seems like the best option.
Is there anything left to do to get this working? I had a blast with F# and MonoGame would love to add support for Godot.
I imagine you already can import an F# dll, but writing a small wrapper around the C# libraries to make them jive with the functional nature of F# is often how this is done.
@voronoipotato how and where do I import the F# dll? During compilation add it to the csproj?
I haven't tried it yet @zetashift but it's often the workaround for engines that use C#. It does seem that you are right though that adding it to the csproj as a reference is the first step.
FWIW this small 3-part article explains how to get started:
http://www.lkokemohr.de/fsharp_godot.html
Edit: Shows how to get started with F# and Godot.
Haha thanks for the link, happy to see I'm not the only one doing this weird stuff.
I wrote a similar how to (but it's in French) here.
@paulloz it's not needed to have an actual class inheriting the F# class. Godot only searches for a file that ends with .cs
and has the class name as file name. Before the mono module got merged I managed to use F# by just creating empty .cs
files with the same name as the desired F# class.
Not sure if that still works, also it's probably not really that relevant to the discussion anyway :)
@paulloz it's not needed to have an actual class inheriting the F# class. Godot only searches for a file that ends with .cs and has the class name as file name. Before the mono module got merged I managed to use F# by just creating empty .cs files with the same name as the desired F# class.
Yay but having this proxy class can be useful e.g. for declaring signals with [Signal]
as (I think), declaring a delegate
inside an F# type is not possible.
Anyway, as you said it's probably not really the purpose of this thread to discuss that ๐
.
declaring a
delegate
inside an F# type is not possible.
https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/delegates
Sorry, this conversation is still out of topic.
@neikeq I don't undertand why you posted this link. Yes you can define delegate
s in F#. I'm was just saying that it can't be done as expected by Godot.
Godot requires to declare type for Nodes.
```F#
type Boat() =
inherit KinematicBody2D()
...
And nesting type is not a thing in F#, this is not possible.
```F#
type Boat() =
inherit KinematicBody2D()
[<Signal>]
type Sunk = delegate of unit -> unit
...
What you'd typically do anyway is a module/type kind of code structure.
```F#
module Boat
[
type Sunk = delegate of unit -> unit
...
type BoatClass() =
inherit KinematicBody2D()
``
But in this case it won't help because Godot will still only know of
BoatClasswhere it won't find any
delegatewith a
[Signal]` attribute attached.
And nesting type is not a thing in F#, this is not possible.
Oh, I see. We could make the Signal attribute receive the type as a parameter. IINW, modules are simply classes with static merbers.
https://github.com/leolimasa/godot-fsharp-boilerplate
relevant here
Closing in favor of https://github.com/godotengine/godot-proposals/issues/191, as feature proposals are now tracked on the Godot proposals repository.
Most helpful comment
F# is quickly becoming my favorite language, and would love to see support for it in Godot ๐