Hacker News new | ask | show | jobs
by MichaelGG 4138 days ago
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.

1 comments

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.