Hacker News new | ask | show | jobs
by jarrettc 4138 days ago
Even though 1.0 isn't out yet, today you can use Rust for many real projects. I'm unsure whether I'd bet my business on it yet, but I'd be open to the idea. And I'm usually a very late adopter.

I've been building a 3d game with Rust and OpenGL, ported from a C++ codebase. So far, my experience has been very positive. Despite Rust's supposed immaturity, it feels more polished than C++ in many ways. Forward progress has been much faster than it was with C++.

Does anyone else have a story (positive or negative) about using Rust in real projects?

3 comments

I'm betting my business on it. I've written a network search engine in F# and it's in use on the VoIP arm of one of the public telcos. VoIP can generate terabytes of signalling data a day, even while not making much money. (In wholesale, many calls simply don't complete, so you've got a huge amount of data and transactions that pay you $0.)

The challenge with F# is controlling memory usage. Even one extra allocation per packet can make a measureable difference in performance. I ended up doing a ton of unsafe code and manually managing most of the heap. Rust allows me to write fairly high-level code (not as expressive as F# yet but whatever) while getting "best" performance. Inline asm is a bonus, as there's some algorithms for integer compression that can use SIMD for big wins (I can do that in .NET, but it's ugly, and doing it safely means a ~30 instruction thunk). And sometimes in tight loops, I've found it difficult to get .NET to do acceptable codegen, causing double-digit% impacts.

There's also the safety issues writing unsafe code for network-exposed traffic. So Rust is actually more safe than .NET, because I have to toss .NET's safety to gain performance.

The backend management code I can continue to write in F#, and Rust's C-compatibility means it's trivial to interop the code. So I can do "orchestration" of indexing daemons and management APIs and such things in a higher-level language, then for actual indexing and whatnot, just jump over to Rust, seamlessly.

Finally the static compilation means a smoother installation experience for customers. And if I ever ship a closed-source module that executes on the client, I don't need to license Mono for static linking. So that's nice. And the safety guarantees are good, because similar, existing, software in C has put customers at risk before. (I'm not sure if I can effectively market that last part, but hey.)

Rust would appear to have a unique value proposition and I'm very pleased to see it progressing so damn well.

Did you give a shot at other languages in the same category as F#, like Haskell, Ocaml, Clojure or Elixir?
To replace the F# side of things? F# is pretty unique as far as performance/language/tooling goes. It's outclassed in specific cases, but overall it's a great package.

The alternatives you listed aren't known for being able to write top-performance idiomatic code (I've got something _working_ in F#, but it's ugly non-idiotmatic code). The overhead of a GC is just too much to pay when doing linerate networking. Rust allows me to keep nice, high-level, idiomatic style, without paying any overhead. I can account for almost every byte.

Here's a company using Rust to sandbox executable financial contracts: https://codius.org/blog/codius-rust/ . The blog post is unfortunately light on details, but I'm hoping to hear more from them soon. I'd also love to see wycats or carllerche weigh in on Skylight.io's use of Rust from within a Rubygem.
Much of the codius code is on github https://github.com/codius
Since you ported from a C++ codebase, how have you handled situations in your game where a lot of inhetitance was used? You may not even use inheritance much in the first place however, just curious about your rust-like solutions for typical c++ game development practices.