by freedomben · 4y ago · 0 comments
Does anybody else have a similar background that can share their opinion/love level of rust?
Rust people: do you use Rust for (nearly) everything? i.e. does it feel very general purpose, or if you are doing something that will be entirely network I/O bound anyway do you reach for something else?
I've used Rust for *nix based IOT programs to ingest data from different sources (network I/O, serial, CAN, files, etc), as well as for bare-metal embedded development. I've also made some dinky webservers as an exercise and various random tooling.
It's a very, very flexible language, once you get over its quirks. I found myself using it to make tools that I would usually turn to Python for. I'm quite impressed with how "high level" the language feels despite being able to work with low-level concepts. Simple stuff like mapping iterators and the Option<T> type while working without an OS is a fantastic feeling.
As most people will likely say, take Rust for a test drive with a basic project to decide for yourself. I would say to keep it simple and not go down the async route as your first foray, though.
As far as things I typically make, database-backed HTTP APIs are probably the most common, and influxdb collectors second most common.
Not Elixir but I spend 10 years in Erlang before moving to Rust and prefer to never go back.
A statically typed language is just better. No matter how easy Erlang/Elixir makes some things. I do not at all miss needing to refactor my code and being scared of all the crashes that inevitably result. I do not at all miss seeing crashes that only show up under production load.
How long did it take you to get to the point with Rust where you wouldn't want to back?
Do you use any sort of actor implementation in Rust?
I do not use an actor framework. It is best to use whatever is standard for the language. For Rust this is Tokio async ecosystem.
I come from higher level language(s). But I find hard to program without functional composition as well.
> Rust people: do you use Rust for (nearly) everything? i.e. does it feel very general purpose, or if you are doing something that will be entirely network I/O bound anyway do you reach for something else?
General purpose language != efficient for all the use cases. I do a considerable amount of hobby programming in Rust, but I think it's a niche language. I think it's vastly most efficient to use other language in the very large majority of the use cases - there are plenty of modern languages the are good enough and don't have such a high overhead (ie. manual memory management). Nonetheless I've found that with a couple of years of experience (likely less than half, if programming professionally), developing with Rust is considerably simpler than one would imagine.
Haskell and the ML family are fine but they just don't have the same number of high-quality libraries with the well thought out modern stdlib of Rust as a base. Elixir/Erlang/Lisps are fine but I'd really like strong, static types. Gleam/Pony are too niche. I'd like to like Scala but every time I try I run into something inscrutable and demonic, and the Java ecosystem is comprehensive but (in my opinion) super annoying.
I love the functional style of Elixir, it's elegant to write and read, but feels unsafe. The lack of a type system is hard for me and has been a nightmare when trying to find the origin of a particular error tuple and refactoring code, running the app to see if it works. Running it in production feels like a ticking time bomb, even if it does handle fault tolerance gracefully.
I've reached for Rust for the occasional project and have never regretted it, I couldn't justify its use for everything though. Very high-quality ecosystem, rock solid and predictable performance and tiny footprint. I've made a VPN supervisor process that fits in a few MB Docker image (without OS), uses a few MB of RAM, no idle CPU and wonderful latency.
Perhaps Erlang can manage tail latencies better under load, pre-emptive scheduling is awesome, but my personal experience has been that Rust is just much more efficient at doing the same task, giving you more free CPU time, predictable memory freeing that rivals Erlang's per-process GC. You finish that blocking computation before it even becomes noticeable. Erlang’s fault tolerance is matched by Rust’s type system and memory safety guarantees. It's hard to compare C++/Rust to Erlang/Python/Ruby, they're just different.
It's slower and more frustrating to write, but the language server gives you so much feedback and useful comments. I find the linter amazing, it finds some pretty obscure and neat improvements with the additional type information it has, and Option<T> and Result<T,E> have an almost functional-like chaining pattern.
For a small hobby project, Rust 100% of the time. No painful dependency management, no complex build process. For a more serious project, or for a client, not always justifiable. I always miss Rust’s language features and libraries when coding in another language that has the upper hand in their respective dominant fields, although I like that a lot of tooling (ESBuild, swc, Tailwind's compiler, fnm, Rome, ...) is being remade in Go/Rust, it benefits far more people than it inconveniences.
Nearly. There are still some things easier to do in Python or JS, but the gap is closing quickly and I'm fine with spending small amount of convenience to get quality of Rust code. I am looking now into having nearly 100% Rust frontend + Rust backend for some simple project and it does look promising.