FyroxEngine / Fyrox

3D and 2D game engine written in Rust
https://fyrox.rs
MIT License
7.61k stars 340 forks source link

Possible Scripting Engine #429

Closed ShalokShalom closed 1 year ago

ShalokShalom commented 1 year ago

I found this: https://www.reddit.com/r/rust/comments/y6k9g9/wrapped_mono_02_run_cf_code_inside_your_rust/

It allows to embed F# into Rust projects.

Considering F# supports many Rust features, and is more usable as a scripting language due it being more concise thanks to global type inference, and a different focus overall.

So I do see, that fsharp can become embedded into Fyrox.

Would you evaluate this?

lenscas commented 1 year ago

Personally, I don't think that Fyrox should support multiple languages like Godot does. Right now, the engine and editor are pretty hackable already as is and from what I've seen I am pretty sure that a single build.rs file (or proc macro), together with Rust's ability to implement traits for types from other crates already allow people to implement their own languages for Fyrox.

They just need some wrapper to make types used in fyrox shareable with their scripting language of choice and a proc macro/build.rs file that at build time generates the types needed on Fyrox's end that corresponds to the types written the scripting language.

I also think that we can do better than embedding mono and that F# as a scripting language doesn't make much sense for Rust projects in general but those are entirely different discussions.

ShalokShalom commented 1 year ago

I do think, having F# as an alternative is quite a different thing to be able to implement own languages.

I want to start with the language I already know, and not implement another language, that might not come with the same editor support, etc than F#.

I take your advice at heart, though, that F# is not suitable as a scripting language for Rust projects.

I generally think, that one of the best approaches to implement scripting in general, is to use wasm.