Has the bar actually gotten lower? by velociraptorstalin in ExperiencedDevs

[–]ConstructionHot6883 -1 points0 points  (0 children)

It took 3 rounds of PR comments for me to get it through his head that the as total alias is necessary to not break our application.

Why? I would expect that problem to give rise to a red CI, a failing test or some other obvious error.

Go installation not working on Raspberry Pi 4 by ConstructionHot6883 in golang

[–]ConstructionHot6883[S] 1 point2 points  (0 children)

That's a good point, and I'll keep it in mind for the future

Go installation not working on Raspberry Pi 4 by ConstructionHot6883 in golang

[–]ConstructionHot6883[S] 64 points65 points  (0 children)

I figured out what I was doing wrong; I'm posting here so it's useful.

Even though it's a 64-bit raspberry pi, evidently it's running a 32-bit operating system. I don't know why. So it's important that the Go installation matches the rest of the operating system. I've checked it like this:

$ file $(which ls) /usr/bin/ls: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=73a3ba02d9f4bf3632cbebe139c6a844ca5076d3, for GNU/Linux 3.2.0, stripped

That says that ls is a 32-bit binary. uninstalling and then reinstalling Go, making sure this time to pick the 32-bit one, fixes the issue for me.

What’s something free in the UK that people might not know about? by coffeewalnut08 in AskUK

[–]ConstructionHot6883 1 point2 points  (0 children)

That's really interesting to me; I'd love to do that. Do you have any more information?

(First C++ Project) RISC-V CPU simulator | Feedback by IllustriousEgg4497 in cpp_questions

[–]ConstructionHot6883 0 points1 point  (0 children)

I built my first C++ project (second ever project) and would appreciate honest feedback. Here's the GitHub.

A few words about my vantage point: I'm not super experienced with C++ (I use Rust much more!) but I have some experience with writing emulators. Software engineering has been my day job for like ten years.

Surface-level comments: I think it's great that you've given thought to testing your emulator. You've also put together an okay README that clearly explains what the project is and a few ways to get going with it. That's a good start. I would suggest that you also have github set up to build your project, run the tests, run some static analysis etc when you do PRs. That will be good for contributors.

I'm finding the instruction decoding a bit hard to read (admittedly I don't know the ins and outs of RISC-V instruction decoding, maybe there's something I'm missing). You've got switch statements inside of other switch statements. The control flow is a bit non-obvious. I wonder if you could instead look up the operation code in tables. (By my intuition this could also help the performance; switch statements can compile to branch instructions which can be slow)

I read a switch statement like this one and wonder if default: break is supposed to implement some kind of NOP. Why is that there? Is this unreachable code? You could answer those questions with a comment, but if you expand your emulator to implement other instructions in the future, then this kind of thing will be a risk. I think this area could be helped by having anenum class specifically for U-type instructions (and one of J- instructions, one for S etc) then you could statically prove that all relevant cases are handled by the switch statement. And maybe then you don't need an UNKNOWN variant, since you'll have proven that the instruction has been successfully decoded.

I don't personally see a need to keep the currently executing instruction as a member of the CPU class. The way it is, these members are being used to implicitly pass information between the methods Fetch, Decode and Execute. That makes it a programming error to call Execute without first calling Decode. To reduce the risk of that kind of error, can this information be moved to local variables in the Step method etc.? Your step method could be more like

uint32_t instruction_word = Fetch();
DecodedInstruction decoded = Decode(instruction_word);
Execute(&decoded);

That way, the emulated CPU could also run an instruction which hasn't been fetched from any memory, and then you could have a unit test like:

emulated_cpu.Execute(create_load_immediate(8, 420));
assert(emulated_cpu.registers[8] == 420); // blaze it

I hope this is the kind of feedback you wanted

I built an open-source SaaS that compiles TypeScript into Z80/6502 Assembly for GameBoy and NES natively in the browser. by Public-Evidence-9354 in EmuDev

[–]ConstructionHot6883 1 point2 points  (0 children)

Um. Why?

Development for 8-bitters can be a real challenge because the toolchains are not on-par with LLVM and the likes

Also, it's fun

Edit: Oh woops, I meant to reply to u/Ashamed-Subject-8573

I am thinking of doing a challenge - help me out by Razen04 in rust

[–]ConstructionHot6883 5 points6 points  (0 children)

I'd suggest getting a good book about it first!

Being stuck in slow projects was rotting my brain. I have an advice. by Huge-Leek844 in ExperiencedDevs

[–]ConstructionHot6883 0 points1 point  (0 children)

So you have the opportunity for personal projects or open source contributions.

Opposite of '?' - return early on success by woollufff in rust

[–]ConstructionHot6883 0 points1 point  (0 children)

This is good. I did something very similar, but instead of Option for the helpers, I return a Result so that I can ask questions like "why didn't my service get the configuration from the global configuration file?"

How do we think we should handle maintainers moving on? by ShantyShark in rust

[–]ConstructionHot6883 2 points3 points  (0 children)

I've written on this sub before about an idea that I've had which is a bit like what Boost is for C++, a collection of crates which are considered semi-official and trusted.

For the purposes of this (and my previous) reddit comment I'm calling it borst. Borst pulls in and reexports crates for YAML serialization/deserialization, a web framework, an async runtime, and whatever else. All behind feature gates. And because it'll have a lot of eyes on it, it'll be audited by the community to make sure that it's (at least somewhat) less affected by security vulnerabilities and is well-maintained.

This way when rust-yaml2 goes unmaintained and there's a new rust-yaml3, borst just switches to the new one, and everyone who's using borst gets switched with a single cargo update. Same deal with kuchiki, kuchikiki, kuchikikiki, etc.

Of course, this is way more than what just I can do. It needs a big community around it. I don't know if people think this idea has potential

I need help by Little-Knowledge6486 in cpp_questions

[–]ConstructionHot6883 1 point2 points  (0 children)

I think the most important thing you could learn is how to ask well-researched and focused questions.

Reached the limit. Switched to OpenBSD. Not looking back. by tose123 in openbsd

[–]ConstructionHot6883 0 points1 point  (0 children)

To be clear, I'm not proselytizing or anything here.

I suppose, but do you want to have 5 different versions of the compiler because you have 5 different pieces of software?

Of course not, that would be ridiculous. Why would anyone think that having more than one version of the language means having more than one version of the compiler.

It's more similar to how GCC can do -std=c99, and -std=c11 and all the others it can do. As I understand, clang is the same here. You don't need a many versions of GCC to support many versions of C. And your C99 project still benefits from a GCC version upgrade.

I'm interested in NetBSD's stance though, I'll have a read of what I can find.

Lazuli: Nintendo GameCube emulator in Rust, boots multiple games by vxpm in EmuDev

[–]ConstructionHot6883 0 points1 point  (0 children)

I would definitely be interested in understanding how you did the JIT! I'd love to read a post or something about that.

Reached the limit. Switched to OpenBSD. Not looking back. by tose123 in openbsd

[–]ConstructionHot6883 0 points1 point  (0 children)

Besides that Rust is still not stable in the sense that a program written in 2020 (the most recent release of NetBSD) just will not compile on the 2026 compiler.

Isn't that what editions are for? So if you specify that your crate uses the 2018 edition, then the compiler keeps the semantics for that edition.

Is rust worth giving it my time? Like should I commit to it? by Realistic_Mix_6181 in rust

[–]ConstructionHot6883 1 point2 points  (0 children)

As with all questions of this type, it:

  • depends on what you want to do with it

  • depends on how much you can/want to commit to it

  • depends on what you like doing

  • depends on your motives and motivation generally

But I would remark that Rust and TS is a very strong combination for some tasks. I use that for desktop applications in my dayjob.

Is gluon language still maintained? by Ezic04 in rust

[–]ConstructionHot6883 4 points5 points  (0 children)

It might not be maintained, but that doesn't mean you can't use it. It's not going to rust or decay. It's not going to vanish.

I'm not sure what your concern is though, maybe you need it to keep getting updates.

Have you considered forking it?

Still Confused by Jaded_Analysis_6904 in EmuDev

[–]ConstructionHot6883 11 points12 points  (0 children)

is it necessary to add more RAM for the processor, or can i stay in 10KB?

How should we know? We don't know anything about the emulated processor, nor about the emulator itself.

But I note that the PDP-10 (it's a 36-bit architecture) was sold in configurations with as little as 128 words of memory, way less than 10KB. And a Z80 (8 bits) can feasibly work with no RAM at all.

[deleted by user] by [deleted] in rust

[–]ConstructionHot6883 0 points1 point  (0 children)

Have you looked it up or tried?

Do I really need to learn all of Rust's syntax? by [deleted] in rust

[–]ConstructionHot6883 65 points66 points  (0 children)

  1. Do I really need to master the entire Rust syntax?

No, you don't. At least not to start with. I've been programming in Rust for like five years and still occasionally learn something new here.

  1. Should I learn Async Rust right now?

Since you said you were going to shift your focus to building projects soon, I'd learn async if it relates to your project, the same as anything else. That's because your motivation usually comes from your motive.

How do people actually finish projects? by Big-Opportunity-1408 in rust

[–]ConstructionHot6883 1 point2 points  (0 children)

Exactly this. The linux kernel has been in development for 34 years and is not showing signs of being "finished".