3 ms·
NPM rewrote one of their services in Rust. It took them one hour to rewrite it in Javascript , two days to rewrite it in Go and one week to rewrite it in Rust.
by DeathArrow 7y ago
NPM rewrote one of their services in Rust. It took them one hour to rewrite it in Javascript , two days to rewrite it in Go and one week to rewrite it in Rust.
Even if we account 90% of that time to the lack of experience in Rust, it still feels like a massive productivity hit.
So unless you absolutely need to squeeze the most performance you can from the hardware it might not be the best choice.
https://www.rust-lang.org/static/pdfs/Rust-npm-Whitepaper.pdf https://www.rust-lang.org/static/pdfs/Rust-npm-Whitepaper.pd...
- siscia 7y agoIt is kinda unfair to compare the time of writing a service in go and rust if your team already work with JavaScript. Go was designed to be extremely simple (simplicistic, if you want to be ugly with terms) while rust was designed with very different goals in mind. Moreover the mental model of JavaScript is much closer to the one of go than the one of Rust. If you are learning rust and you are not from C/C++ or similar low level languages you are basically re-learning how computers works. Usually on go you don't really care of the difference between the stack and the heap, in rust you have to. Said so, it is really true that rust has a steep learning curve, however once you get over it the productivity is at least as high as go especially in the long term. For one off script of ~100 lines I would pick go as well.
- IshKebab 7y agoSure but it's worth noting that they went with the Rust implementation in the end even though it took the longest to write. Their reasons appear to have been that Rust code has fewer bugs (who cares if you get your JS code done in an hour if you spend a week fixing trivial runtime bugs?), had better performance, and they didn't like Go's dependency system. I definitely have noticed when writing Rust code I spend way more time getting it to compile, but I also have that "wait it worked first time? Impossible, I must have done something wrong" feeling waaaay more in Rust than I ever did with C++ or Typescript. I'm even starting to get used to it and think "sure it worked first time, it compiled after all!". I wonder how their opinions on Go would change though, given that it now has arguably the best designed dependency system of any language.
- SCdF 7y agoSo two things. First the actual quote: > The rewrite of the service in Rust did take longer than both the JavaScript version and the Go version: about a week to get up to speed in the language and implement the program. So that was an hour for a programmer who knew JS, and then a week for a developer who didn't know Rust. Secondly, to me those times are acceptable, because they don't tell the whole story. JS is very easy to quickly prototype things in, but that doesn't mean it's great to maintain. Just yesterday in our JS code we have found in some places we are writing timestamps as an epoch number, and some places we are writing them as a DateTime string. It's not as fast as native code, nor as easy to parallalise, etc.