reso icon indicating copy to clipboard operation
reso copied to clipboard

Hello world

Open ashirviskas opened this issue 3 years ago • 6 comments

Hey there!

I just started learning rust and as a small exercise, I've made an implementation of reso from scratch on rust. And I was wondering whether you'd like to connect these projects?

My code is still a bit messy and needs some refactoring, but it's not too slow (~0.25s per step on my machine) and could be used for creating an interactive WebAssembly interface. Let me know what you think!

Link to my implementation: https://github.com/ashirviskas/rust_reso

ashirviskas avatar Feb 12 '22 23:02 ashirviskas

Update: Time per step is actually ~0.07s on my machine when running a release build.

ashirviskas avatar Feb 13 '22 09:02 ashirviskas

Hi! Wow, this is awesome. I am a total rust noob, and I think this is awesome!! This is seriously cool work. I am definitely interested in connecting, maybe even making this the 'primary' implementation.

I got this to run on my machine, and this is blazing fast in comparison. This makes it feasible to doodle circuits and work with them. (The Python implementation crawls on anything of size.)

I'm going to poke around with this next weekend!! I'd love to learn some Rust while poking around and studying the code.

Re merging: I think the best plan is to keep implementations separate, combined under a GitHub organization. (So, specs, implementations, GUIs, etc.) I can work on that next weekend as well! For now, I've linked to the Rust implementation in the Readme.

Do you mind if I link to this and @ you on Twitter?

(I also still have a lot I want to do that is language agnostic, but I haven't really prioritized yet: Writing a formal spec, adding a native "compiled graph" format, adding more circuit components and tests, and making some kind of dev forum. )

Again, amazing work-- I can't wait to poke at this in-depth next weekend

lynnpepin avatar Feb 13 '22 19:02 lynnpepin

Hey, thank you so much! I'm still a rust newbie and this means a lot to me.

As you probably saw, this project is still very WIP and missing some functionalities that you have. Also, lots of undefined behavior (the most recent that gave me some pain in my circuits was two outputs connected to a single wire).

I'll also try to implement at least as much as you have in Python, but I might get busy this week. Though if you're willing to iron out some of the details, I'd be happy to work on it in Rust.

Sure, GitHub organization sounds good! And feel free to mention me (@Ashirviskas) or my project.

One more thing, what are your thoughts on the license? My code still does not have any, but I'm probably leaning towards something GPL'ish (especially if we continue this as a truly free and open source project)

ashirviskas avatar Feb 13 '22 21:02 ashirviskas

Hi! Sorry for the late reply. I spent some free time this week familiarizing myself with Rust.

For a Rust reimplementation, this is my rough plan:

  • Clean up this repo. (Proper structure, with src/ and tests/ and whatnot. Cleanup the LICENSE)
  • Use Python as the "official" implementation (at least for now).
  • Reimplement RegionMapper.py, Palette.py, ResoBoard.py, and Reso.py
    • Rust drop-in replacements, using PyO3 and Maturin.
    • Re-use the same Python unit tests if possible.

Once this is done, I think "community building" with organizations, etc. is the next step. This path would probably be a big refactor from your code, but I think I'll still reuse big parts of it.

As for the LICENSE, I'm conflicted between GPL and MIT. It seems Rust projects are overwhelmingly dual-licensed with MIT and Apache. Does MIT sound right with you?

lynnpepin avatar Feb 19 '22 18:02 lynnpepin

Hey, it's alright! I've cleaned up the code a bit in the meanwhile. And I see you've just updated yours, neat!

I've got to admit, I hadn't run or looked at your python implementation, as I wanted to do mine from scratch using a more rusty approach (though I'm still a noob) and just now I've started to familiarize myself with yours. I like the way you implemented everything with extensibility in mind, though I'm still not sure if I like the exact approach (palette.py looks a bit verbose, especially with the number of imports you need to do). But you're the owner of this project, so you're free to do what you want to! I still might want to contribute to your project after you're done with all the changes.

I might want to keep my repo as a separate implementation and try out a few things if you don't mind.

Sure, I have no objections to the MIT license. I'll put my code under MIT soon, so feel free to copy my code for your implementation!

ashirviskas avatar Feb 20 '22 12:02 ashirviskas

This is a good point. My architecture probably isn't the best, and might be even less ideal when applied to other languages.

The palette.py is probably one of those spots! What worked well here for Python might be ugly to someone who knows Rust better.

The main goal with palette.py is to make it easy to map between (1) a character representing a color, (e.g. 'R'), (2) a short variable name for the color (e.g. pR), and (3) the RGB value for that color (e.g. (255, 0, 0)). Using from palette import * is safe, even if generally considered harmful.

The important parts are in ResoBoard.py (which might be thought of as the lib.rs) and the __main__.py (formerly reso.py, which might be thought of as the main.rs`, providing the CLI.)

But the main point is, I'm not particularly committed to one architecture in Python, let alone in Rust.

I might want to keep my repo as a separate implementation and try out a few things if you don't mind.

Yeah absolutely!! I have no claim over your implementation. I don't have any super cemented ideas for "the best" path for a Rust implementation anyway, as someone who is even newer to Rust :D

I'll put my code under MIT soon, so feel free to copy my code for your implementation!

Will do!! I'll try to keep my eyes off it, but just for educational purposes.

lynnpepin avatar Feb 21 '22 01:02 lynnpepin