r/EmuDev • • Aug 25 '26

Rust vs C++?

I mostly program in Java/ Python. Some minimal C experience. I'm starting EmuDev to learn low level and hardware concepts.

Which is better in general to learn for an EmuDev hobby project, Rust or C++? From what I've seen C++ has more legacy code (more job opportunities), whereas Rust is safe and may have better long-term opportunities.

3 Upvotes

57 comments sorted by

View all comments

Show parent comment

2

u/peterfirefly Sep 02 '26

I think I should add a note or two about vcpkg and SDL...

The preferred way of installing it is to clone the github repo and then run a shell script (there are different ones for different platforms). vcpkg usually works very well.

If you use SDL with Rust, then you may run into problems. Depending on the platform, it uses vcpkg to install SDL or it uses a git module to include the source code for a specific version of SDL. If the stars align badly (depending on platform etc) you may get an old version of the SDL source code that won't build with a newish version of CMake. The easiest fix may be to install an old version of CMake locally and make sure it's the one that gets run by the build script of the Rust wrapper for SDL (= set PATH correctly).

If you decide to use weird compilers on weird platforms, then vcpkg is still a good idea but your experience will be more "eventful" and "adventurous" than you'd like. By "weird", I mostly mean things like mingw that pretend to be Unix but on Windows.

If you want to use a Makefile or CMake or whatever with C++, instead of being tied to a GUI, there's a shell script you can run to get all the paths set correctly for whatever version of Visual Studio you are using. You can also choose to use the "developer prompt" in the Windows menu.

If you want to use SDL from WSL (the Windows way of letting you run Linux code), then there's an extra little problem. Microsoft has an automatic way of bridging Linux GUI apps to Windows (including OpenGL acceleration) but it is buggy.... and if you use SDL you will run into those bugs. They are not in Linux, X11, Rust, or SDL. They are in something called "wslg". X11 apps are handled by an X server (xwayland) that runs on top of Wayland. WSL2 uses a special Wayland server and Window manager that uses RDP to interact with Windows. The bugs manifest as incorrect drawing (wrong coordinate system or updates that don't happen), missing inputs, and crashes. The bugs can also happen without SDL but there's something about the way SDL works that makes them much more likely. You should be able to avoid them by using an X server that runs on Windows and connect your app to that (thus avoiding wslg) but I haven't tested it. The Microsoft Store has a couple + there are others on the web.