Maybe you can combine Rust and Elixir by speeding things up with Rust NIFs.
You can do incredible things with little effort thanks to Rustler
If by casual user, you mean the 95% case of a back-end developer whose main job is pulling data from various sources, performing operations, and placing that data elsewhere and/or displaying it to an end user: nothing, really.
Rust excels at performance, but the bottleneck in modern web apps is going to be IO, whether that's loading data from a database or from a third-party API you're integrating with. Rust excels at correctness, but your errors are going to come from bad data and system outages which require manual intervention anyway. Rust excels at security, but if you're using a GC language running on a Docker container on an ephemeral cloud instance, the kind of security Rust provides isn't a likely attack vector for you.
All that being said, Rust is a great language! It just has its niche, and that niche is not the typical web-dev back-end work that most developers do these days. As others have said, you'd use Rust in the same situations you'd use C++: building a database, building a web server (like nginx), etc. If you're just building a web app that talks to a database and serves HTTP responses, stick with Python/Ruby/Go/PHP.
This is true in some senses, but also, response latency isn't the only thing a web application does or is evaluated by. Many applications have, for example, background jobs, that do arbitrarily complex processing outside of the request/response cycle.
Additionally, people who write web services in Rust talk about decreased memory usage, consistent memory usage, and lower CPU usage. In a cloud context, that can translate directly to revenue saved, by spending less. If that tradeoff is right for you depends on a variety of things, of course. "speed" isn't the only relevant metric that you may want to optimize for.
This means that you don't accidentally forget a null check (or a catch block) and, in my experience leads to software that is a lot more robust.
Even if all it is doing is pulling from a database and munging it into JSON.
With that said, it's okay if there isn't much in it for you. If it doesn't sound useful for your current use cases, that's okay. Don't use it. Use things because they are interesting and fun or because they make your life better. Don't feel the need to use it just because it's on The Orange Site a lot.
It's probably not a good first language, but neither was C++: that's not its niche.
Actually both C++ and Rust tend to make heavy use of reference counting via `std::shared_ptr<T>` and `Rc<T>/Arc<T>`, respectively. Personally I think that while Rust's borrow checker is nice for some cases and does encourage fast/efficient memory usage, it's also overkill vs automatic memory management for even most system or real-time programming. Especially as compilers get better and can remove 90% of the reference counting spots.
Also it’s just plain fun sometimes. I love expression based syntax where you can assign to an if or have a block result in a value. It just feels delightful. The standard library is very constrained but within those constraints it has a lot of wonderful depth. Functions like split_once or unwrap_or_else are delightful to use. It gives me that same feeling as Ruby where the language feels designed to have you enjoy writing code. The language has all of the requisite tools I want to model data structures including tuples, structs, and enums. It’s great! Try it out and see for yourself
In languages without spread operators (like java), immutable objects are quite clumsy to work with: I want this same object but these two fields changed (like the replace method on python's named tuples, but those are also annoying...). But with mutable objects, everyone can mutate: chaos. Rust gives you the mut keyword, structs are immutable by default.
Ever wanted to implement a method on a class in another library that just used the public API? Just make your own Trait in rust.
Ever wanted to make sure that someone would call `close()` on your implementation? Ever wanted to make sure that no one would use the object afterwards? That's garbage collection of a resource that isn't memory, most GC languages won't manage that for you, but the borrow checker will.
Pattern matching, algebraic data types, expressions and statements distinctions, an excellent build system, procedural macros, no null, no exception handling, good type inference; none of these are new or unique to rust, but lots of languages lack a few to many of them.
But yeah, some times I don't want to decide between monomorphisation via generics, or heap allocating for dynamic dispatch. Some times I just want a JIT and a garbage collector to take care of that for me. But that is another thing rust might give you: a newfound appreciation for what you have.
A feature of modern computing is the use of very low power systems (I programme mostly for Raspberry PI - not very low power) and/or systems run on "pay as you go" platforms which can scale hugely.
Rust is very efficient at run time. (Not at programming time nor compile time) so is very useful in these cases.
A counter example, from my life, to illustrate: I ran a mail server for a group I was involved with. I spun up a VPS and Mailman. (Mailman v3 is built on Django/Python). I had to double the capacity of the VPS as 500MB of memory was not enough to install and run Mailman (I think the problem was at install time, but that made very little difference). The cost of my mail server doubled because of the inefficiency of the Django/Python framework.
Django is very efficient at programming time, but is resource hungry. The original Mailman ran in 40k, the "modern" version was not usable on a platform with 500MB.
For me it was no biggy. One server, $10 not $5 a month. Mēh! But if that were a million instances.....
So with all the progress in computers getting more powerful the actual instances we use are getting weaker (for very good reasons). A language like Rust can be very helpful in this case.
(On the Raspberry Pi I use Rust for realtime control of audio processes)
That being said, there are also downsides - apart from the steep learning curve, compilation is pretty slow and the language itself isn't as good as some others for prototyping - if you make something simple and want to go fast, then maybe TypeScript will do a better job, despite its numerous problems.
Rust is more about robustness and correctness (and performance of course). If these are not appealing to you, then sure some other languages like Java, Go, C#, TypeScript or others can do the job.
I’ve used a bunch of common languages, Python, JavaScript, Typescript, PHP, Bash, Go etc. Not so common languages such as Haskell.
My first choice for personal projects is now Rust.
The memory/borrow checking to me is just a nice benefit I get from using Rust, I don’t use Rust for the borrow checking.
My main reason for Rust is while it’s not as high level as say Java/Python etc I find it is still at a nice level to work with and can be far more expressive with the enums, traits and generics.
The second big reason I use it is my programs end up fast and efficient with little effort.
The third reason is I can get tiny statically linked binaries that just run anywhere with no dependencies.
Reasons two and three mean I can host my applications on the cheapest, most minimal resources available and still outperform other languages on more expensive hosting. Currently my choice is to stick the binary in a Docker image which ends up sub with a sub 10mb docker image then deploy on the smallest 128mb AWS lambda and pay fractions of a cent to host. Services that need to be long running go on the smallest $5-10 vps’s .
The borrow checker can be a pain however I find the compiler error messages really helpful in it often tells you what you should do to fix the problem with plain English error messages and code suggestions.
---
I'm not sure I agree with the article's premises. Rust can be difficult, yes, but it can also heighten developer productivity above other languages. In Go, I'd have to worry about whether I checked for exceptions via `if err != nil` everywhere, while with Rust, I can depend on the compiler telling me if I haven't done so exhaustively, via the Result type. Same for having algebraic data types or, well, generics in general.
I will also push back on other commentors here saying Rust is not good for web apps and APIs, and I have found that to be the opposite of true. I read Zero To Production In Rust [0] (a great book by the way, all about creating a web API with actix-web and Postgres) and deployed an API that has not gone down a single time since deploying near the beginning of this year. It's as ergonomic as (and sometimes even more so than) any NodeJS or Go API I've made (as even though Rust doesn't have function overloading, actix-web and others have some macro magic they do behind the scenes to make it appear as if it does), and there were very few times I had to contend with the borrow checker. If there had been and if I were really going for speed, I would also have cloned everywhere that was needed.
When I write something in Rust and it compiles, I can depend on it to work, and to continue working. At the end of the day, use the tool that makes sense for your business, but I don't think Rust was necessarily a bad choice based on my personal experience with it.
[0] https://www.zero2prod.com/
---
IMO the strengths of the language are not a deal-breaker for a casual user (e.g. someone writing CRUD or line-of-business applications)
But doing a rewrite requires Rust programmers and they hard to hire.
Rust is quickly growing into Golang and Java's space for web services.
My startup uses Rust in production for our web APIs, and we're really happy with it.
[1] You'll probably need to spend a few hours learning the language basics, but it's really easy at this point with the docs and best-in-class compiler error messages.
But, before you can make anything meaningful with a language, you have to first make many toys. That's the rationale for using it in cases where there are better alternatives. (To make you comfortable using it when there is a need for it.)
Because I already know Rust, and prefer it as a language generally, it’ll be my default choice, just like you have your default choice. It works well for many cases in the backend, but not all of them, like lots of technologies. If you don’t find a compelling reason to switch, you shouldn’t!
For me the biggest win with Rust is the performance that I can get out of it, which is irrelevant in most cases. If you work on a problem that requires extreme single node performance then you can learn Rust instead of learning C++. This is probably less than 10% of the use cases people use programming languages for. As far as teaching juniors: I had great success with Python, yet, a lot of foot-gun situations. With Rust I am not good enough to mentor our junior devs, so we learn together. It goes very slowly.
Rust is genuinely only useful for the niche application of a desktop application, that doesn't reach low level, but you need a bit more fine grain controls than C# or another higher level language will allow. For example, a web browser is like the ideal usecase for Rust, and it makes sense, since that's really where it's got most of it's teeth with Mozilla.
I personally don't see why you would do something like Grep, in Rust, when C#, Python, Go, exist. But I do see like Unreal Engine or again, Firefox/webbrowser in Rust being nice.
For backend web dev: Skip it. I prefer Python/Django.
Rust does attract a weird subgroup of people who can get preachy and pushy about there only being one way to do things.
But the helpful part of the community is much bigger and much better to work with. You just have to look past the loud people pushing agendas and stay out of flamewars on Reddit and HN.
I've seen more comments talking about this supposed phenomenon than instances of this phenomenon actually happening. I haven't really seen any examples of preaching and cult-like reactions, I just see people talking about how it supposedly exists somewhere.
I agree with you that it can be really off-putting. From my perspective what you are seeing could be more of a comment on some of the know-it-all dilettante types who fawn over trendy tech in comment sections than the rust community itself. I've always had great experiences when reaching out for help in discords, user forums or other spaces. I've seen similar patterns with other trendy technologies in the past too.
I want to have a function that returns the UTC now as a string. Now what? Opening a question on SO -> question closed, here is a question about &str and String that has nothing to do with the use case and everything about the implementation details of &str. Good stuff.
I think the creator of Rust assume that if they explain where a piece of data is allocated suddenly everybody is going to be on the same page about the use of that data.
That said, being an outsider, I'm reminded of this quote from a recent article:
> "What was the deal with [person X] on your team, why are they such a jerk?" (Sadly, if you worked on Chrome you probably know exactly who I'm talking about.) The experience gave me an appreciation for how a group, especially a faceless internet group, can be perceived by its worst behavior.
Source: https://neugierig.org/software/blog/2022/12/chrome.html
Also, what can you criticise about Rust? /s
Completely agree, but for a different reason:
The community and leadership is overran with woke leftist types. It's insufferable.