Game Developer
Rust Evangelist
JS Zealot
C++ Hater
Programmer
Python Fan
Web Technologies Radical
Python is an interpreted language which also means it has a heavy runtime and overall slow ecosystem which makes it a problem to use it for Computationally heavy work.
Additionally, the GIL also locks the multithreaded compute to a single thread which adds to the problem.
Rust is a system level programming language that allows for great flexibility, control and safety while maintaining blazing fast performance.
fn add_vec(v : &mut Vec<i32>) {
v.push(4);
v.push(5);
}
fn main() {
let mut x = vec!(1,2,3); // mutability is explicit
let v1 : &i32 = &x[0];. // X[0] is borrowed
add_vec(&mut x); // error x already has a borrowed ref
println!("{}", v1);
}
void add_vec(vector<int>& v) {
v.push_back(4);
v.push_back(5);
}
void main() {
vector<int> v(1,2);
int &v1 = v[0];
add_vec(v); // mut ref vec
cout << v1 << endl; // might cause a segfault
}
Rust follows a similar philosophy to C++ in terms of offering zero-cost abstractions and it deliveries quite well on the promises it makes.
Most if not all that you use in Rust has modern syntax familiar to those who use languages like Python while providing almost zero overhead.
Cargo is the package manager and crate host for rust. Akin to npm for JS, or PyPi.
And yes we call Rust packages crates.
Cargo allows you to use simple commands to install, create and manage crates.
reduce() , map() , filter()
modules are a first party participant of Rust lang
Writing a module that is supposed to be accessed via another language is usually very hard to do.
Involves setup on both sides and interfacing with complex FFI functions and generating binary or channels of communication.
But due to the fact that Rust lacks a runtime and support C ABI interfacing.
We can actually use CFFI.
Of course, there is a better way we are talking about Rust here. :P
And it involves using Python Bindings that generate Python Interpreter use ready binary with absolutely zero Python code or use of complex FFI systems.
rust-cpython is the original project but you can use PyO3 (it's fork) for greater flexibility, although this only supports Rust nightly builds.
Deserialization performance of Hyperjson. (Rust Py Module for JSON parsing) https://github.com/mre/hyperjson
Simplejson & Rapidjson both are/use C and C++ libs repectively.