#Watch a bunch of Rust wannabes cry about code formatting
27 messages · Page 1 of 1 (latest)
let mut i;
let mut j;
let mut k;
let mut l;
let mut w;
let mut h;```this kind of thing where you lay out the variables ahead of time is discouraged, just declare the variables when you initialize them
like seriously that formatting and often not indenting in things like while loops is 
//Sweep over 3-axes
let mut d =0;
while d<3 {
// code
d += 1;
}```This should be written like this ```rs
for d in 0..3 {
//code
}```Assuming that `d` is not modified elsewhere in that loop. The for loop version is much more readable because its not possible to modify `d`
@manic pagoda
not sure if you saw it
yes thank you, the code I typed up in a single day with 0 rust experience isn't perfect. I had a specific question.,
I'm aware it can be cleaned up
just suggesting a few things that would make the code better in general, so its easier for people to try looking at it
alright thanks
Robo's just trying to help. And I agree, cleaning up the code would be a big help toward understanding what its performance bottlenecks might be. And just copying JS to Rust 1:1 doesn't necessarily mean that the program should run the same between both languages.
As it stands, it's going to be really hard to analyze this code by hand in order to potentially make recommendations of how to improve the speed. To answer one of your specific questions, no, casting probably won't make a huge difference.
I already figured it out
rust is just too slow compared to javascript it is what it is, fun language though
wasm is slow, if it was running natively it would definitely be faster
I was only joking I actually fixed it already
WASM runs over 2x as fast as the JS now 😄
but basically two command line command recommendations, cargo fmt to format it, then cargo clippy for code cleanup suggestions
no
what did it end up being? (was watching the conversation at the start)
I was using the js_sys::Uint8Array type, and I was using get_index for each lookup, so what I did instead was
let data: Vec<u8> = volume.to_vec();
at the start to convert it into a "rust array" for lookups.
and now my hard work has payed off
it runs SO much faster than the javascript, im impresse
Watch a bunch of Rust wannabes