#First Rust project

2 messages · Page 1 of 1 (latest)

nova pumice
#

I'm currently on 30% progress on the Let's Get Rusty bootcamp, but I wanted to alredy use Rust to try out how its perform for what I want to use it for. I made 1 year ago a PHP API for a game mod (bc the original server died), I wrote it in PHP. Later I rewrote it into C#, but sometimes it's ate 2GB RAM idk why (usually it ate about 200 MB) and I decided I will firtly try out rust on this, so I rewrote the C# API into Rust. Currently its eating about 40MB inside a Docker container.

And yeah, thats why I didn't use JSON, have ".php" ending of the links, etc. (Backward compatibility.)

What do you think about, what I should to change to make it better or more Rusty?
https://github.com/FemLolStudio/gachaplus-rust-api

GitHub

A Rust version from the original PHP API with 100% backward compatibility. - GitHub - FemLolStudio/gachaplus-rust-api: A Rust version from the original PHP API with 100% backward compatibility.

crude geode
#

It's great to hear that you've been experimenting with Rust and have noticed significant improvements in memory consumption compared to your PHP and C# implementations. It seems like Rust is well-suited for the task, especially considering its focus on performance and memory safety.

As for making your Rust implementation even better and more idiomatic, there are a few things you could consider:

Error handling: Rust has a robust and expressive error handling system using the Result and Option types. Make sure to leverage Rust's error handling capabilities to handle errors in a more structured and ergonomic way.

Use Rust's standard libraries: Rust provides a rich standard library that includes modules for networking (e.g., hyper), serialization (e.g., serde), and many other common tasks. Leveraging these standard libraries can improve the maintainability and performance of your code.

Concurrency: Rust has great support for concurrent programming through constructs like threads and async/await. Depending on the nature of your API, you might consider utilizing Rust's concurrency features to improve performance and responsiveness.

Memory safety: Although it seems like you're already benefiting from Rust's memory safety features, it's always good to be mindful of memory management in your code. Avoiding unsafe code and using Rust's ownership and borrowing system effectively can prevent common memory-related issues.

Community and best practices: Engaging with the Rust community and learning about best practices can provide valuable insights into how to architect your Rust code in the most idiomatic and efficient way.

Overall, it sounds like you're off to a great start with Rust, and there's plenty of room to continue refining and optimizing your API implementation. Feel free to ask more specific questions or share any particular challenges you encounter as you continue your Rust journey!

As the result, if it is ongoing project, I wanna participate in your project