Hacker News new | ask | show | jobs
by max_ 1033 days ago
So far the only solid use case for Rust that I have seen in applications where security is extremely important.

Not wonder it is becoming the de-facto language for building applications in the blockchain space.

Does anyone else use Rust outside the blockchain/cryptography space? What are you working on?

19 comments

At my $BIGCORP, we have a multi-mode (discrete/continuous) simulation engine written in Rust. It has to be extremely fast, and interface with both firmware written in C, and scripts written in Python. C++ was the only other viable option, but none of us were confident writing safe and performant C++, so we picked rust instead.

Now that I've been using rust for ~5 years, I reach for rust for when I have to do almost anything else. I write small backend services in rust[1], and small utilities that would previously have been python scripts[2]. The only thing I still use any other language for is python for writing test scripts + interactive data exploration, and typescript for front end stuff. We still use a lot of C for firmware because the Rust target support isn't as good as C yet.

[1] you might argue that Go might be better suited for this, but I disagree. The lack of null safety and less strict typing would come back to bite me a lot. A typical backend service we write is 10x simpler than our simulation engine so 1) compile times are approx the same as the project is small and 2) we usually don't care that much about performance for these services so we can just clone or RC away any problems we might have with the borrow checker. Swift might be a nice, but the ecosystem isn't there for backend apps last time I looked.

[2] Total LoC for small scripts ends up being about the same for python/rust in my experience. Development time is approx the same, but I much prefer maintaining small rust apps when I come back to it after 6 months. You _can_ set up safe and maintainable python projects with external libraries for validation, but its too much effort when rust has it all out of the box. Also, python deployment/venv management is still immensely frustrating

> Does anyone else use Rust outside the blockchain/cryptography space? What are you working on?

I work at Materialize which is building database software in Rust. One of my coworkers blogged about our experience with the language here: https://materialize.com/blog/our-experience-with-rust/

Im using it for a highly multithreaded real time web app. Also i disagree with your assessment, i think rust can really be used for everything.

For the business im building the frontend is written in js but everything on the backend is rust. i needed one highly multithreaded realtime server and rust was the right choice for that. For everything else (api, file server) I decided to just use rust too, maintaining a node backend and a rust backend and having to deal with typescript build systems when i could just use rust for everything made my life easier.

What ive found is that open source authors interested in releasing libraries in python and nodejs choose to write it once in rust then release python and js libraries using rust ffi.

See polars, yrs, rapierjs, lancedb, candle, etc.

It's become rather popular in the graphics (e.g. https://wgpu.rs/) and game dev (e.g. https://bevyengine.org/ ) spaces.

It's pretty popular for AWS Lambda functions.

Pretty popular for terminal / shell applications.

Definitely a great way to write wasm for compute or graphics intensive browser/web apps.

I use it for a desktop file transfer app [0]. I chose Rust because my primary language is Python and I just wanted to learn something new and really different for this project. Go would have been easier, but Rust just feels bullet proof. It's so strict. If it compiles, it works! It's been a very interesting journey.

[0] https://github.com/transmitic/transmitic

Linkerd's sidecar proxy (https://github.com/linkerd/linkerd2-proxy) is implemented in Rust. It implements transparent mTLS, HTTP load balancing, telemetry, etc. Rust gives us safety and security with a minimal resource footprint.
Rust is just a nice general purpose language. It's good more or less everywhere.

There are a few places where I wouldn't recommend it - for beginners, when compile time is really important (e.g. as a scripting engine in games), or where you need a repl (science).

But otherwise it's a better choice than most languages for most tasks.

For our client, we've developed a desktop application in Rust – with a thin GUI frontend in C++/Qt – to filter, process, and visualize sensor data streams (3D point cloud data from a Lidar). Each data stream was about 400-500 Mbit/s in 55k UDP packets per second, with support for at least 4 simultaneous streams. The focus was on high performance and development speed, security didn't matter at all.

We chose Rust for its unique position in the performance/productivity tradeoff space, and didn't regret it even for a second. There's no way we could have pulled this off with C++ in the same time, especially the bug-free parallelization.

Why use C++ for the front-end though?
We selected Qt as a cross-platform solution. The C++/Rust interface is the clunkiest and ugliest part of the application, and rather complex because some state is shared between several windows in the GUI and several threads in the backend, and any component might modify that state at any time, and updates have to be transmitted to the other components without introducing inconsistencies. However, using cxx [1] helped a little.

The project began in 2020, and I'm not sure what I'd choose as a GUI framework today – definitely not Qt Widgets, though.

[1] https://cxx.rs/

Yes, in fact I see hardly any cryptocurrency stuff with rust.

I'm building an OS in rust, and write most firmware with rust too.

> Yes, in fact I see hardly any cryptocurrency stuff with rust.

Really?

Solana [0] a top 10 market cap cryptocurrency is written in Rust and so is its smart contracts.

NEAR Protocol is another [1] one as well as Sui [2] and Polkadot [3] written and using Rust.

[0] https://github.com/solana-labs/solana

[1] https://github.com/near/nearcore

[2] https://github.com/MystenLabs/sui

[3] https://github.com/paritytech/polkadot-sdk

I didn't say it didn't exist. I said I don't personally ever see any cryptocurrency stuff in my Rust experience aside from coming across a few crates here or there related to it.
As an outsider with some good feelings towards Rust and some negative one towards crypto, almost all Rust jobs I’ve seen have been in crypto
That's a fair point, my experience as well. I think I was mostly talking about the code I see on e.g. GitHub.
All of our core code is Rust and even in web backend and k8s tooling at http://www.ditto.live

Been a great choice even with trade offs like needing to train some hires and compilation speeds.

I'm building a 2D simulation game compiled to WASM using Bevy!

It's nicer writing in Rust than JS, no GC makes Rust a good WASM candidate, theoretically the performance can be better if you're careful, people take 2D game engines more seriously in lower level languages, and it keeps the door open for shipping on Steam later.

I've found it much slower to develop in, though. Compilation times are an issue and after working in JS for decades I realize how big the JS ecosystem is compared to something like Rust.

I doubt the decision was a good choice overall in terms of trying to ship an MVP, but it might still pay dividends for a finished product, if the game gets there, due to having a higher cap on performance

Defect language in the blockchain space is still JS/TS. Not sure you should be relying on their signals for security assurances.
I am talking about building nodes that execute the underlying consensus protocols. Not the front end client side applications.
> So far the only solid use case for Rust that I have seen in applications where security is extremely important.

Playing devil's advocate, when is security not extremely important, except maybe in throwaway bash script-type applications?

* Toy one-off scripts, not even shell scripts necessarily

* Small things for one's personal use or local network use only

* Quickly prototyped experiments, as long as they're not used in production

* academic/scientific research
Games. The attack surface for third-party input is very limited, and you can just secure those bits rather than adopting a new language for the entire program.

Like, you need to be able to sandbox mods if they're a thing, and Rust's memory safety only handles a tiny part of that.

Multiplayer games have huge attack surfaces.
Single player games maybe, cheating in multiplayer games can be big business.
Only hobby coding, leetcode stuff and such.

Work is all about Java, .NET, Web and mobile OSes, Rust hardly brings anything to the table there, other than less capable tooling, higher attrition with existing ecosystem and complexity in designing borrow checker friendly algorithms versus automatic memory management.

> So far the only solid use case for Rust that I have seen in applications where security is extremely important.

But that's basically anything that touches the internet.

Not having buffer overflow vulnerabilities in your communications code is huge.

> Does anyone else use Rust outside the blockchain/cryptography space?

Cross-platform desktop app development, systems programming and authorization which is still cryptography related, I guess.

I use it for one off stuff I used to use Ruby for at the hobby level. The learning curve was high but it is very easy to reason about correctness.
I've used Rust for years in embedded Linux devices and more recently in signal processing.
there are some data processing projects, www.pola.rs for example