Is it possible to write a plugin in rust?

I’m new to development and also would love to start learning rust instead of c++, is this a reasonable thing to ask? Or is it just not possible right now?

1 Like

You could write but it would have to be rewritten in C++ in order to compile.

I haven’t investigated Rust, but I imagine there’s some way to use C++ apis from Rust. The bigger challenge is that a plugin has to conform to particular C++ function signatures; if there’s a way to call out to Rust from C++ you could write a wrapper to forward the required functions.

It seems like kind of a pain in the ass actually; most of what you might want to do in Rust would be almost exactly the same (modulo minor syntax differences) in C++.

Actually looking at what is involved with calling C++ from rust, this seems like a nightmare.

It looks easy enough to expose Rust to be called from C++. So you could make a standard C++ plugin/module and call rust code inside the functions.

Again the problem is that a large percentage of Rack module codes is calling Rack APIs to do things, so each of the Rack functions you want to call will have to be wrapped in FFI, and I have no idea how you can capture C++ objects in rust and call their member functios.

I’m not familiar with Rust myself if you wanted to learn basics of coding from it I’m not too sure how similar C++ is in comparison. However easier languages to learn from are C# and Java which are fairly similar to C++ and translate well.

I know how to code, I just like rust more than c++ and don’t have many project ideas for getting to know the language more, so I thought I could maybe write some vcv rack plugins.

Thanks for the info chaircrusher, I’ll read about calling C++ apis from rust

Well, learning C++ is a use case to writing plugins for VCV Rack!

If you know rust then I can’t see why you couldn’t google search things like “[insert rust syntax] C++”

I could for sure! I just like programming in rust more and want to learn more about the language by doing a project.

All credit to you if you get the wrapper @chaircrusher talked about working!

1 Like

No, this is not possible. You shouldn’t bother trying it unless you’re an expert at C++, Rust, linkers, and compilers and want to waste a colossal amount of your time vs. simply writing a C++ plugin.

I tinkered with it for a couple days over the summer. If memory serves, I ran into a wall in getting the code to compile as a C++ class so that the dynamic libraries can be loaded by the runtime and find the expected functions.

My memory is hazy, but I remember doing a lot of dumping of symbol tables and trying to force things to line up, and then giving way the hell up.


I agree with @Vortico that by the time you got Rust bindings working satisfactorily you’d have spent less time learning how to write a C++ plugin.

That being said it isn’t absolutely impossible, and a cool idea in the abstract. There are tools like this that can ‘automate’ generating Rust bindings.