Skip to content
/ calc-rs Public template

Template project for using Rust for Python, Java, Rest-API and WASM

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

brmmm3/calc-rs

Repository files navigation

calc-rs

calc-rs is a template project for using Rust in Python, Java, WASM and as Rest-API service.

The project is a workspace containing the following packages:

  • Rust. This is the main package containing all the logic. It is intended to be used in other Rust projects without any dependency to pyo3 and jni.
  • Python. The Python layer for creating the Python module.
  • Java. The Java layer for creating the Java module.
  • WASM. The Web Assembly layer for creating the WASM module.
  • REST-API. The REST-API server extension.

Recommendations

For learning Rust you should read this book. You REALLY should read this book before you start coding, because Rust is not easy to learn. Especially to understand and solve the findings of the Rust compiler can drive you crazy. But in the end, after solving all the findings you'll understand that the compiler was absolutely right and it saved you a lot of future work finding and fixing the bugs by yourself.

For testing simple code examples online, without installing Rust locally, you can use the Rust playground.

If you've issues you can't fix then it is a good idea to ask in the user forum. My experience is that you'll get useful help within a short time. When asking questions you can use the playground to paste a short (working) example, which describes your problem.

And last but not least at This Week in Rust you'll find interesting news and projects.

IDE

For programming Rust the best IDE is VS Code with the following plugins:

  • Rust Extension Pack
    • rust-analyzer
    • crates
    • Even Better TOML
  • Prettier - Code formatter (Rust)
  • Microsoft C++ on Windows
  • CodeLLDB on maxOS / Linux
  • Python, if you plan to develop Python extensions.

A short guide can be found here.

A promising alternative is RustRover. A feature rich Rust IDE from JetBrains. Currently preview releases are available. If you plan to develop Python extensions then you should install the Python plugin.

Code quality

To improve the code quality I use clippy, which is a very powerful linter.

Conclusion

Rust is a very versatile power horse. It is easy to use Rust in most used programming languages. For web applications Rust can be used on the server side with REST-API and on the client side with the wasm-pack.

My preferred combination is Python and Rust. If the application has a UI I usually use Qt. For very simple UIs FLTK is preferred for smaller executables and easier license handling. In Rust I implement the performance and security critical parts. The rest in Python for reduced development costs.

If speed and / or security matters I would really recommend using Rust. The power features of Rust helps you reducing bugs and follow up costs.

License

Licensed under either of

at your option.

About

Template project for using Rust for Python, Java, Rest-API and WASM

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published