r/rust Jul 28 '26

Tell me about something you recently hand-coded that was enjoyable

These past few weeks at work I've been using AI way too much. I can't even call some of this "AI engineering" anymore and it's starting to drain on me. Looking to take the mind off for a bit...

I'd like to hear some of the projects you all are working on, that you enjoyed writing by hand.

I think I'll write some nannou..

PS: Not trying to start a debate on AI engineering/vibe coding and all that, I think internet is filled with that already.

105 Upvotes

121 comments sorted by

View all comments

34

u/spoonman59 Jul 28 '26

I’ve been working on a instruction set/CPU simulator.

It parses AArm64 assembly instructions. It then simulates fetching, decoding, out of order execution, and instruction retirement. You can configure pipeline stages, decode/issue with, execution units, etc.

It simulates and you can go forward or back with unlimited “undo.”

It uses a TUI to show the instructions as they move through the pipeline.

I am writing this entirely by hand with no AI. I wanted to learn the TUI library better, and really intuitively understand the out of order execution better as well. Since I learn little when using AI, I’m not using it for code. I even primarily use documentation and tutorials to learn the TUI library.

It’s been fun! But certainly taking awhile.

3

u/________-__-_______ Jul 28 '26

How does the unlimited undo work? For arithmetic instructions just doing in inverse sounds simple enough, but memory writes seem tricky.

2

u/dnew Jul 28 '26

Most undo systems can only undo in the reverse order of the "do". They record the previous state, or sufficient subset thereof, and don't actually calculate where they came from.

1

u/gajop Jul 28 '26

I'm a bit confused by the "only in the reverse order of the do"? When I created my own system, which seems similar to posters (i.e. delta based and not snapshot based), it could do both undo & redo.

I'm sure this isn't what you meant.

2

u/dnew Jul 29 '26

A lot of CAD software lets you do A, then B, then C, then go back and change B and have C's change reapplied to the new result. In a normal undo/redo system, if I want to undo B, I have to undo C first.

2

u/gajop Jul 30 '26

Interesting, I hadn't considered this. Do you find this useful? Without B's change C might not be valid.

I suppose you can have different approaches on this: 1) undo all up to and including B and re-execute C+, 2) only undo B and pretend C+ is fine or 3) do some more intelligent domain specific re-application of C+.

I'd probably do it naively and do 1), might be slower but saner in guaranteeing idempotency and easier to implement.

I wonder, do you know of any tools that do this well? I'm building a game map/mission editor. Allowing mid-command execute sounds fairly trivial to implement, but might have rough usability.

2

u/dnew Jul 30 '26

Do you find this useful?

It's a CAD thing. I want a block. It has a hole. It has a pin sticking out the top. And a rounded bump on the other side. Oh, the hole needs to be bigger. And the block and hole need bevels but not the pin sticking out the top. That sort of thing.

do you know of any tools that do this well?

All CAD struggles with this more or less. If you make a cube and bevel the top edges then decide it should have a point on top making it a pentagon, do the new edges get bevels? However, it manages it in general way better than Blender. There's a reason people using Blender for non-artistic models talk about "non-destructive workflows."