Apologies for the late reply. Python and Rust are fairly different in a lot of ways. I think it’s fair to say they’re about as different as apples and oranges. They’re not as different as Lisp and C or Haskell and Ruby, but they’re rather different.
It can be challenging to describe what makes languages different from each other in a way that’s meaningful (or at least not surface-level) and approachable, but it can help to start with “what languages want to do as primary goals and what they don’t care about as non-goals.” Python cares about ‘readability’ and ‘productivity’. It does not care about ‘speed’ or ‘portability’. A project written in Python is harder to deploy on another system because it requires a whole constellation of dependencies that can’t be packaged with a given file. Python is “fast enough”, but not particularly fast, especially compared with C or Rust. Python has a LOT built into the standard library and language. They call this, “batteries included”. By comparison, C and JavaScript are extremely barebones. Rust cares about safety and speed over compile time and development time.
On the surface, Rust and Python have a fair number of differences, too:
Trait \ Language |
Rust |
Python |
Objects/Classing |
Trait-based |
Inheritance Based |
Syntax |
Curly braces |
Whitespace Delimited |
Runtime |
Compiled |
Interpreted |
Typing |
Strong+Static Typing |
Duck/Weakly Typed |
Standard Library Philosophy |
Minimalist |
Complete |
Programming Paradigm |
Mostly imperative |
Mostly imperative |
Environment and Build Tooling |
Great (Cargo) |
Great (pip + pyenv) |
(Before folks yell at me about the ‘mostly imperative’ or the typing comments, I know these are simplifications.)
Updates to the original discussion, while we’re here:
In the time since the original reply was written there has been a veritable Cambrian explosion of learning solutions in Rust. I still personally enjoy using Python as the first place to develop models before moving them to Rust, but there are great options now:
dfdx - dfdx - Rust - A pure-Rust CUDA accelerated learning toolkit.
Burn - GitHub - burn-rs/burn: Burn - A Flexible and Comprehensive Deep Learning Framework in Rust - A flexible and comprehensive deep learning framework.
tch-rs - GitHub - LaurentMazare/tch-rs: Rust bindings for the C++ api of PyTorch. - Bindings for the Torch library in Rust.
tract - tract - Rust - A tiny, self-contained, no-nonsense library for using pre-trained models in Rust.
Candle - GitHub - huggingface/candle: Minimalist ML framework for Rust - A minimalist library by HuggingFace for deep learning in Rust. Very new.
Of these, I’ve only used tch, tract, and Candle. tch has a more friendly interface and can load PyTorch models, but includes the whole of the Torch library making for HUGE (near-gigabyte, last I checked) executables. Tract is the one I use most often for integrating trained ONNX models. Candle is a relative newcomer and doesn’t load architectures the same way that ONNX loaders will, but is still a quite promising candidate and I’ll probably spend some time playing with it in the months to come.