Hacker News new | ask | show | jobs
Nand2Tetris Hack assembler implemented in Rust (github.com)
71 points by tamuhey 2209 days ago
13 comments

As always, I can't recommend this course enough, it's a really enlightening dive through the layers that make up a computer, and I presented about my experience with it at a Python meetup.

With that said ...

1) They respectfully ask that you not share your solutions, so as to ensure others have to figure it out or ask for help in the forums.

2) Why share the assembler specifically? That's probably the least difficult or interesting project, as it's mostly just translating the mnemonics to binary.

3) Holy code duplication! [A] Surely Rust allows you to break off a simpler structure that just represents the mapping from assembly to binary, and then you can have one loop that does the insert/to-owned on each element?

[A] https://github.com/tamuhey/hack-assembler-rust/blob/master/s...

I followed your advice and closed my repo.
I was also a student of Prof. Schocken's in person, as well as part of the tech crew for a non-profit coding bootcamp he set up[0].

While I agree that posting this publicly is less than appreciated, he is VERY enthusiastic about seeing implementations in interesting programming languages, as far as I can remember from my class (last year). I sent him a link to the original repo, which will now be dead.

Would you be interested in forwarding a private link of some sort? I could forward it over.

[0] https://wecode.org.il/

I'm very interested about your idea. If he approves, I'll make the repository public again. If there is a better way to share my code with him, please let me know.
Sent him an email. Let's see what he says.
He's indeed interested in seeing your implementation - how can he reach you without disclosing his private address here?
Great course! I had the pleasure of doing it with the mentoring of Prof. Schocken in Israel (and being graded on it... :) )
Lucky you to have great teacher.
Same as shayas above - took his class in school. Some impressions from talking to him and working with him in his coding bootcamp:

1. He is a very, very funny dude.

2. He has no tolerance for bullshit, and will be very quick to shut you up if you are making no sense.

3. Having said that, he is VERY nice, and always points you in the correct direction, even if you are deeply mistaken.

4. He was one of the first people to push for Java in CS schools in Israel, when he was the founding dean at the IDC [0]. This might seem like a weird thing to mention, but in hindsight it cemented the use of modern programming languages in academic curriculums here, which is not a small feat.

5. He has a deep appreciation for the application of Computer Science in the wild, the likes of which I have not seen in many CS professors. He seems like a coder by heart, and that's why - I think - Nand2Tetris speaks to many of us: It is a very theoretical book, presented in a maker-y type fashion: build, build, build. Love it.

[0] https://www.idc.ac.il/en/pages/home.aspx

P.S. If you have some way of assisting the bootcamp (financially or otherwise), drop them a line over at info@wecode.org.il. Donation of services will probably also be appreciated, if possible.

Nice! I did this too[0], I highly recommend the exercise.

[0] https://github.com/levi/hackassembler

I did Nand2Tetris in Python as it was what I was familiar with at the time.

I think using a much stricter language like Rust would have saved me a lot of heartache.

(Thing you normally wouldn't care about)...implemented in Rust.
Implemented in Rust/Python/Elixir
Upvote Collector.... implemented in Rust!
It seems anything is newsworthy here when it's in Rust
Next you'll have to implement a Rust compiler in Hack!
I have also implemented this exercise in rust although the one posted here is much cleaner in terms of code.

In fact I was even trying to reimplement the hack cpu emulator provided in the course using rust and tui-rs. The main hurdle now is how I can emulate a 512x256 screen in the terminal.

Last year I was going through this book because I always wanted to know how computers were made from the ground up.

I got to the assmebler exercise and really wanted to figure out how to implement it in the assembly language itself to see how that step was once taken. After that I was going to do the exercise in python.

I really should pick up that book again and just implement the assembler in python, so that I can move forward.

I love the book.

Is this part of the second half of the course ? I don't remember implementing an assembler, but I only did the 1st half ;)
The end of the first part. Although it's optional. In the start of part two they make you do it if you skipped it in part one.

I did it in javascript. I didn't really miss typing. Although when things went wrong a lot of debugging was needed. But I think these were logic errors iirc. I'm not sure if typing would have helped.

In part two you build a stack-based virtual machine and then javaesq programming language, that is built on top of the assembler you built in part one.

It is the last project in the 1st half
I did it in VB6
Nice work.

The amount of ".to_owned()" just begs to use some kind of macro though.

Yeah I'd appreciate if a rustacean would explain the canonical way of DRYing that up, at least if it's non-obvious, something other "run a loop over a variable holding the dictionary literal".
I'm seeing a 404 now.
I'm sorry I closed this repository because of what the other user mentioned.
What a pity, I was hoping to read the code and see what I could have improved in my implementation.
Anyone else having trouble running it?