Live data from Hacker News

Implementing a NES Emulator in Rust

michaelburge.us

31–40 of 93 posts

Re: Implementing a NES Emulator in Rust

#31
post #25

Earlier quoted context omitted.

I am not sure you can not use `unsafe` in an embedded type of project. `unsafe` isn't necessarily bad, but when used at least makes it very clear where extra attention should be paid.

Emulating a system of a few 2Mhz with a 4x3Ghz chipset ought to be doable using managed memory.

Except that an explicit goal of the project was to run simulations much faster than real-time to train an AI to play the game, so they still wanted to squeeze the the maximum performance out of the program.

Re: Implementing a NES Emulator in Rust

#32
post #25

Earlier quoted context omitted.

I am not sure you can not use `unsafe` in an embedded type of project. `unsafe` isn't necessarily bad, but when used at least makes it very clear where extra attention should be paid.

Emulating a system of a few 2Mhz with a 4x3Ghz chipset ought to be doable using managed memory.

Nitpicking a bit, but there's not a lot of useful things that could be multithreaded in an 8-bit emulator, so it would be more like 1x3Ghz ;)

In those old 8- and 16-bit machines all components usually ran completely synchronous for each clock tick, for instance if the video emulation runs out of sync with the CPU emulation for a tick or two, a write from the CPU to a video hardware register might not make it in time and you get garbage video output.

Modern asynchronous systems may need less (relative) host system performance for emulation, because the timing requirements between the different hardware components are much more relaxed.

Re: Implementing a NES Emulator in Rust

#33
post #30

What is something that I can do to learn Rust better? I have been through the book, but that's it. What would help me really learn Rust?

For me, I’ve been rewriting my simple scripts and old school projects in Rust, which has been both enjoyable and informative.

Project Euler problems are pretty trivial (wrt coding) but might have some small useful nuggets. The code advent calendar from 2018 is pretty helpful too, and it’s much more code oriented than PE problems.

I’ve seen people suggest rewriting the GNU coreutils, and I really like the idea, but not quite enough to go sifting through all of the C headers and all to get to the finish line.

Honestly, it probably doesn’t matter much what you start coding as long as you’re coding.

Re: Implementing a NES Emulator in Rust

#34
post #30

What is something that I can do to learn Rust better? I have been through the book, but that's it. What would help me really learn Rust?

What about a command line utility to do some basic Unix tasks? Usually those are the easiest and usually also very fun things to do to learn Rust.

Re: Implementing a NES Emulator in Rust

#36
post #30

What is something that I can do to learn Rust better? I have been through the book, but that's it. What would help me really learn Rust?

"How do you get to Carnegie Hall?"

Seriously, the best thing to do for virtually all professional or hobby work is to get more experience with it. Choose a project with small enough scope to give you encouraging results to keep that feedback loop going.

Re: Implementing a NES Emulator in Rust

#37
post #2

Question, what made it easier to build this in Rust than other languages? I know the advantages of Rust, but what exactly was the experience in this context?

It seems that unsafe references were used, so the advantages of Rust appear to have been somewhat relinquished in this case.

To declare the advantages reliquinshed requires some kind of discussion of the `unsafe` blocks' scope. How many, how much code?

Regardless, I'm not even sure I'd say that memory safety is Rust's biggest advantage. It's certainly the headliner and it's critically important. But it's a really appealing package overall IMO.

Re: Implementing a NES Emulator in Rust

#38
post #30

What is something that I can do to learn Rust better? I have been through the book, but that's it. What would help me really learn Rust?

"How do you get to Carnegie Hall?" Seriously, the best thing to do for virtually all professional or hobby work is to get more experience with it. Choose a project with small enough scope to give you encouraging results to keep that feedback loop going.

[deleted]

Re: Implementing a NES Emulator in Rust

#40
post #6
post #2

Question, what made it easier to build this in Rust than other languages? I know the advantages of Rust, but what exactly was the experience in this context?

The author doesn't really suggest that Rust was chosen for any particular reason. A few benefits are mentioned but they aren't really specific to emulators.

Because why not?
Post reply on HN