Hacker News new | ask | show | jobs
by mutatio 3542 days ago
Created http://encycolorpedia.com a few years ago, kind of neglected it until recently (it's looking very dated), a version implemented in Rust is 90% complete - cheaper to run (more beer money, thanks Rust team!) & more features than the node.js implementation it will hopefully replace in the coming weeks.
2 comments

> 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.

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.
Glad to hear it's working out! If you ever blog about the experience, let me know.