rewrite it in rust #1

Merged
SonicSwordcane merged 20 commits from riir into main 2024-11-10 23:34:55 +00:00

I was struggling to build a cross-platform desktop application with C, both because I'm a novice at C (and native applications in general) and because there weren't many libraries to do what I need.

Rewrite the app in Rust instead of C. Use winit for window management and cpal for audio, instead of SDL. Use wgpu for graphics; it's backed by the same libraries as SDL, but also supports portable shaders. Use Dear ImGui rust bindings for a GUI, instead of nuklear.

Rewriting the app in Rust has a few advantages:

  • I actually know Rust, so I can develop more quickly.
  • FFI is reasonably easy, meaning that the project can use C libraries (shrooms-vb-core) and C++ libraries (dear imgui) without makefile surgery.
  • Rust has an installer, package manager, and distribution tooling. All of these are automatically cross-platform and fairly easy to set up.
  • Rust has a high-quality portable standard library and many easy-to-use "crates"/packages, so I don't have to spend a lot of time writing/integrating an .ini parser/CLI parser/ring buffer/dictionary
  • Rust is cross-platform by default, so I am a lot more confident that this will run on OSX.

There's some downsides too:

  • Not a ton of people in the VB community know Rust, so it'll be hard for other people to contribute.
  • Builds are way slower, especially in release mode.
  • The app is much bigger (rust binaries are already big, and I pull in libraries like a node.js dev).
  • The app is slower than a pure C application. I haven't set up cross-platform LTO, and winit/wgpu do more than SDL did. However, I don't think it's noticeably slower, since the VB only runs at 20mhz anyway.
  • I think this loses compatibility with Windows XP (Rust runs there, but winit is relatively new and might not support old-timey platforms like that).
I was struggling to build a cross-platform desktop application with C, both because I'm a novice at C (and native applications in general) and because there weren't many libraries to do what I need. Rewrite the app in Rust instead of C. Use [winit](https://github.com/rust-windowing/winit) for window management and [cpal](https://github.com/RustAudio/cpal) for audio, instead of SDL. Use [wgpu](https://wgpu.rs/) for graphics; it's backed by the same libraries as SDL, but also supports portable shaders. Use [Dear ImGui rust bindings](https://github.com/imgui-rs/imgui-rs) for a GUI, instead of nuklear. Rewriting the app in Rust has a few advantages: - I actually know Rust, so I can develop more quickly. - FFI is reasonably easy, meaning that the project can use C libraries (shrooms-vb-core) and C++ libraries (dear imgui) without makefile surgery. - Rust has an [installer](https://rustup.rs/), [package manager](https://crates.io/), and [distribution tooling](https://opensource.axo.dev/cargo-dist/). All of these are automatically cross-platform and fairly easy to set up. - Rust has a high-quality portable standard library and many easy-to-use "crates"/packages, so I don't have to spend a lot of time writing/integrating an .ini parser/CLI parser/ring buffer/dictionary - Rust is cross-platform by default, so I am a lot more confident that this will run on OSX. There's some downsides too: - Not a ton of people in the VB community know Rust, so it'll be hard for other people to contribute. - Builds are way slower, especially in release mode. - The app is much bigger (rust binaries are already big, and I pull in libraries like a node.js dev). - The app is slower than a pure C application. I haven't set up cross-platform LTO, and winit/wgpu do more than SDL did. However, I don't think it's _noticeably_ slower, since the VB only runs at 20mhz anyway. - I think this loses compatibility with Windows XP (Rust runs there, but winit is relatively new and might not support old-timey platforms like that).
SonicSwordcane added 17 commits 2024-11-10 19:37:02 +00:00
SonicSwordcane added 2 commits 2024-11-10 20:25:45 +00:00
SonicSwordcane added 1 commit 2024-11-10 20:53:34 +00:00
SonicSwordcane added 1 commit 2024-11-10 21:08:56 +00:00
SonicSwordcane force-pushed riir from 94cb5a542d to 99d6970323 2024-11-10 23:22:10 +00:00 Compare
SonicSwordcane merged commit 9fcf6b3dc5 into main 2024-11-10 23:34:55 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: PVB/shrooms-vb-native#1
No description provided.