News for hackers. Stuff that matters.
Re:Next steps for Rust in the kernel by antegamisou on Wednesday September 21, 2022 @09:09AM (#32924634)
> You want to learn how computers think, pick up an assembly language.

For which you'd need to be familiar with a low-level language like C.

Re:Next steps for Rust in the kernel by ImprobableTruth on Wednesday September 21, 2022 @09:20AM (#32924768)
... no? In fact I think learning assembly before C makes a lot more sense than the other way around.
Re:Next steps for Rust in the kernel by orobinson on Wednesday September 21, 2022 @09:45AM (#32925072)
This. The computer science degree I did started off in the first term with us building computers on an FPGA by mapping out the logic gates, then programming it in assembly. Learning how to program in C followed this.

It's a good way of helping people with no programming knowledge get past the stage of "what are those magic colourful words you type that somehow make the computer do things?".

Re:Next steps for Rust in the kernel by stjohnswarts on Wednesday September 21, 2022 @10:07PM (#32934062)
I think this is an awful way of learning for beginning CS students. It will scare off too many good kids who think this is all that CS will ever be. Top down is better. Bottom up is only going to be good for people who adore computer architecture guts and want to start at the bottom from first principals. Most kids want to use computers as a tool and not learn it's atomic structure.
Re:Next steps for Rust in the kernel by stjohnswarts on Wednesday September 21, 2022 @10:05PM (#32934051)
Unless you're experienced well in some other language then assembly is going to scare you off. I learned assembly by looking at -O0 output from c compiler code. Then I went ahead and dived in. Just doing bare assembly is not somewhere a beginner should start unless they are just absolutely in love with low level programming.
Re:Next steps for Rust in the kernel by jcranmer on Wednesday September 21, 2022 @09:17AM (#32924738)
No, you don't. In the curriculum I've taught, assembly was taught before C. As long as you have any programming language experience, you should be fine with assembly--I've explained it in terms of even MATLAB before.
Re:Next steps for Rust in the kernel by Filligree on Wednesday September 21, 2022 @09:19AM (#32924759)
Assembly was my first language. I had no trouble picking that up, and in fact didn't meet a compiler until ten years later. They were much too expensive at the time.
Re:Next steps for Rust in the kernel by HideousKojima on Wednesday September 21, 2022 @10:27AM (#32925616)
I learned CHIP-8 asm and Gameboy asm before ever touching C
Re:Next steps for Rust in the kernel by pwpw on Wednesday September 21, 2022 @10:36AM (#32925786)
I want to learn how to build emulators for CHIP-8 and Gameboy and am having the person tug-of-war over assembly, C, or Rust. With hindsight, do you recommend doing them in assembly? And what resources did you use to get started?
Re:Next steps for Rust in the kernel by HideousKojima on Wednesday September 21, 2022 @10:58AM (#32926095)
I wrote my CHIP-8 emulator in C#, actually. I used the Godot game engine for rendering and sound (though I never actually got around to implementing sound). The language you write it in really doesn't matter too much unless you really care about performance, or if you want to do something fancier than an interpreter (like a JIT recompiler). I used this guide:

https://tobiasvl.github.io/blog/write-a-chip-8-emulator/

I haven't made a Gameboy emulator, just learned the assembly so I could modify some roms.

Re:Next steps for Rust in the kernel by gotlou on Thursday September 22, 2022 @09:16AM (#32938381)
I wrote a CHIP-8 emulator[0] a while back in C using SDL2 for rendering everything. It still has a couple issues with the timers and taking input. I was new to C back then so I did this project to become more familiar with it.

You can check out my blog post[1] if you're interested how I went about it (there are a couple resources at the bottom I used to build it, including the one that HideousKojima recommended).

As for language, in hindsight, C was fine. CHIP-8 is so basic that you don't really need to worry about performance or to implement a JIT compiler unless you want to learn how to do those things specifically. Just pick any one out of the three (assembly is a bit of a weird choice though, why not write a CHIP-8 emulator and then a brand new program to run on that emulator in CHIP-8 assembly if you want to learn assembly?)

As for Gameboy, it would have more instructions, a different graphics system, sound etc. and overall be more complicated than CHIP-8. Try it out if you either feel a bit more adventurous or have implemented CHIP-8.

[0](https://sr.ht/~gotlou/chip8-emulator) [1](https://gotlou.srht.site/chip8-emulator.html)