Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello world #4

Open
ashirviskas opened this issue Feb 12, 2022 · 6 comments
Open

Hello world #4

ashirviskas opened this issue Feb 12, 2022 · 6 comments

Comments

@ashirviskas
Copy link

ashirviskas commented Feb 12, 2022

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
Copy link
Author

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

@lynnpepin
Copy link
Owner

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

@ashirviskas
Copy link
Author

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)

@lynnpepin
Copy link
Owner

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?

@ashirviskas
Copy link
Author

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!

@lynnpepin
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants