SomeRanDev / reflaxe.CPP

An alternative C++ target for Haxe that generates dependent-less, GC-less C++17 code.
MIT License
72 stars 5 forks source link

Do you have an example of mixing with Rust? #3

Open nanjizal opened 1 year ago

nanjizal commented 1 year ago

I am curious on Pop_os interest and attempts to complement/replace linux gui's with Iced, found a tutorial on use. https://brianch.github.io/iced-twentyone-tutorial/01intro.html

So I am wondering as a Haxe user how easy it might be to code Iced in Haxe with your c++ target ?

Through suggesting this I hope to clarify a real world use that Haxe community may have. Iced seems a use, which is not going to compromise any private use cases which you would not be able to share. I think coding Iced in Haxe would be something that would really excite users and bring new users, the concept would make an excellent example use... if it is at all viable and show Haxe being used outside game industry.

Having only read a book on Rust my knowledge is very limited, so I have no idea how feasible, and not being a c/c++ coder I do not think I can assist currently, feel free to close but injecting the idea in hope. I realise this would be more than a Hello Rust use case, but one that would really test your implementation choices.

SomeRanDev commented 1 year ago

I can totally do a Rust integration example! I am a huge Rust fan, so would definitely like to try that once this project is a bit more stable. However, when it comes to working with Rust frameworks... that's a bit outside the scope of this project. This project can help run Haxe code in Rust (cause the generated code can run without dependencies or runtime), but running Rust code in Haxe is a different story.

While calling C++ from Rust isn't that difficult, arbitrarily calling Rust structs and functions from C++ is impossible without wrapping them in #[no_mangle] and extern "C" (afaik)? So unfortunately, being able to use Rust libraries in Haxe would require wrapping the Rust to work with C++. However, based on the provided tutorial, that Rust framework is heavily reliant on Rust traits, enums, and other Rust exclusive stuff that is impossible to easily port I'm afraid.

Not to mention, when it comes to calling existing C++ code, the official Haxe/C++ target is already just as capable as this project is when it comes to simple function/struct calls. So... even if you go through all the effort of exposing Rust calls in C++, it's not like this project in particular would provide any benefit.

Sorry if this was not the answer you were hoping for >.<

nanjizal commented 1 year ago

mainly just curious, I am not convinced that coding in c/c++ is for me, and feel should be using something low level that blends well with haxe. I have no commercial need apart from being considered code employable!