
Nand2Tetris Hack assembler implemented in Rust - tamuhey
https://github.com/tamuhey/hack-assembler-rust
======
SilasX
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...](https://github.com/tamuhey/hack-assembler-
rust/blob/master/src/main.rs#L11)

~~~
tamuhey
I followed your advice and closed my repo.

~~~
tomgs
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/](https://wecode.org.il/)

~~~
tamuhey
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.

~~~
tomgs
Sent him an email. Let's see what he says.

~~~
tomgs
He's indeed interested in seeing your implementation - how can he reach you
without disclosing his private address here?

~~~
tamuhey
Thanks! My email address is written in my github profile page:
[https://github.com/tamuhey](https://github.com/tamuhey) Please tell him the
address.

~~~
tomgs
Oh! Sweet. Actually only saw the LinkedIn and sent you a request there. Will
also send an email.

------
shayas
Great course! I had the pleasure of doing it with the mentoring of Prof.
Schocken in Israel (and being graded on it... :) )

~~~
stormdennis
Lucky you to have great teacher.

~~~
tomgs
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](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.

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

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

------
alexgmcm
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.

------
mastrsushi
(Thing you normally wouldn't care about)...implemented in Rust.

~~~
nurettin
Implemented in Rust/Python/Elixir

------
gitgud
Next you'll have to implement a Rust compiler in Hack!

------
ducaale
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.

------
InfiniteBeing
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.

------
tryum
Is this part of the second half of the course ? I don't remember implementing
an assembler, but I only did the 1st half ;)

~~~
tarkin2
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.

------
barking
I did it in VB6

------
pjmlp
Nice work.

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

~~~
SilasX
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".

------
mywittyname
I'm seeing a 404 now.

~~~
tamuhey
I'm sorry I closed this repository because of what the other user mentioned.

~~~
ducaale
What a pity, I was hoping to read the code and see what I could have improved
in my implementation.

------
gtsnexp
Anyone else having trouble running it?

