godot-rust / gdnative

Rust bindings for Godot 3
https://godot-rust.github.io
MIT License
3.62k stars 210 forks source link

Can we simplify GDNative Rust? #144

Closed Raj2032 closed 4 years ago

Raj2032 commented 5 years ago

I truly wish we can use Rust but I it feels a lot more complicated than C# when typing code, take a look at how simple C# is.

using Godot;
using System;

public class YourCustomClass : Node
{
    // Member variables here, example:
    private int a = 2;
    private string b = "textvar";

    public override void _Ready()
    {
        // Called every time the node is added to the scene.
        // Initialization here.
        GD.Print("Hello from C# to Godot :)");
    }

    public override void _Process(float delta)
    {
        // Called every frame. Delta is time since last frame.
        // Update game logic here.
    }
}

Isn't it possible to simplify GDNative Rust as much as C#? Especially since Rust is better than C# in terms of performance?

karroffel commented 5 years ago

As mentioned in #143, I am working on a procedural macro to reduce the boilerplate.

We will not be able to match the ergonomics of C#, as Rust lacks things like introspection which C# uses to automate those processes.

Raj2032 commented 5 years ago

@Raj2032 If the boilerplate is managed to be reduced, then how close would GDNative Rust would be to C# in terms ease of programming?

karroffel commented 5 years ago

Rust will still be more explicit in many ways, like the difference between user-classes and actual Godot objects, as well as many functions being unsafe etc.

Rust is just more verbose, so I don't think we will be able to match C# terseness.

Raj2032 commented 5 years ago

@karroffel How do I compile this on Windows, as when i attempted to compile this on Windows then I got an error message

thread 'main' panicked at 'Unable to find libclang: "couldn\'t find any valid shared libraries matching: [\'clang.dll\', \'libclang.dll\'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"', libcore\result.rs:1009:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
karroffel commented 5 years ago

I don't know how to set it up on Windows, but it looks like you need to install clang.

Raj2032 commented 5 years ago

Thanks

Raj2032 commented 5 years ago

@karroffel So I managed to get it perfectly working on Windows which is great. But here is this one issue.

So I moved some stuff around, and how come Visual Studio Code thinks that I am in this directory E:\Godot example\godot-rust1\examples\spinning_cube\Cargo.toml when it is located in this directory E:\Godot example\godot-rust1\examples\spinning_cube\Assets\Code\spinning_cube.Cargo.toml?

Here is the error message when I hover my mouse above the issue.

image

shijunti19 commented 5 years ago

Please give me a complete Windows compilation tutorial windows10

Raj2032 commented 5 years ago

I forgotten how to do this but I asked those tech guys on Discord in Godot and they taught me how to do this for Windows, its a bit confusing and I didn't understand it, Windows is shit for software development I hate how they make it such a crappy platform for development.

MrMinimal commented 5 years ago

@shijunti19 I can't give you a complete tutorial because my Windows 10 machine is not a fresh install. Still - if you get the Unable to find libclang error, you have to install Clang's pre-built binaries from their website.

ghost commented 4 years ago

Closed question due to inactivity, unclear objective, and derailed discussion.