Hacker News new | ask | show | jobs
by unlimit 3542 days ago
> a version implemented in Rust is 90% complete - cheaper to run

Is it cheaper to run because of Rust? Why is it so? Could you please explain, don't know anything about Rust though.

3 comments

A lot of the colour space calculations are orders of magnitude faster using Rust (LLVM). This would be the same story had I chose C/C++ of course, but Rust was chosen in part for educational purposes.

I had originally started the re-write in Google Go, but I experimented with Rust and had a much better performance profile for the more CPU intensive stuff like using the more modern Delta E methods (https://en.m.wikipedia.org/wiki/Color_difference).

I had to use the more primitive colour distance calculation methods for the node.js/JS implementation (CIE76). Not only that, I also had to cache the output after the first run. Using Rust I can use better colour difference methods, do it in real time AND get more requests/sec.

I should add I still use Go on the API side of things.

Rust code is likely to be very much more efficient, reducing the server requirements.

I wouldn’t expect this site to have particularly high requirements, but hey ho.

(Example: NewsBlur was at a certain point using about 50 servers, for a specified load that by careful calculation I am confident would fit on one server (though not with much headroom) if it were written sensibly in Rust, rather than however it is in Python/Django.)

Nodejs's strength is that you can write code quickly and it handles IO well. The drawback for nodejs (and similar languages like python, php, ruby) is that they are incredibly slow, especially for CPU bound work like calculations. People use the slower language because it's simply easier and faster to be productive in some categories of projects.