6 ms·
> What does Rust solve for the casual user? If by casual user, you mean the 95% case of a back-end developer whose main job is pulling data from various source
by mjr00 4y ago
> What does Rust solve for the casual user?
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.
- steveklabnik 4y ago> but the bottleneck in modern web apps is going to be IO 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.
- cogman10 4y agoDon't forget startup and distribution time. It's not terribly hard to have a scratch rust container which is about as slim and secure as you can get. That container will startup pretty much instantaneously even if it's cold. You are looking at ~5mb container vs 200+mb if you did a jvm based container. It's probably overkill for most applications and companies, but it's something to keep in mind if you need fast scaling for cheap.
- makapuf 4y agoFor webdev Go scratch containers are really nice and quick to develop. Of course the language could use better error checking but that's about it. It really does that job well. Fast, secure (GC and yes you can ignore errors the same way you can unwrap() the world).
- brabel 4y agoRust will be much lighter than any JVM app, but a fairly complex JVM app can be compiled to a self-contained JVM distribution on around 25MB these days... you use jlink to compile the app and parts of the JVM that you actually use. Not to mention you can use GraalVM native-image to compile to a binary directly, in which case it'll be even smaller.
- zozbot234 4y agoStartup time is a great feature for all sorts of FaaS environments as well. Especially when combined with Rust's generally low resource use.
- alephu5 4y agoGo has these same properties
- mjr00 4y ago> 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. Yeah, for sure -- I deal with a web app that does complex, time-consuming analytics in data pipelines with Python, and Rust could help a lot with improving some of the complex calculations. But again, that's more using Rust as a C++ replacement rather than looking at replacing, say, the Python-Flask frontend that serves up the results of those analytics. > 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. It'd definitely reduce costs, but yeah, be sure to get a full picture here from a business perspective. Engineers love to optimize AWS costs, but it isn't appropriate in a lot of situations. In my case, I'm paying a nontrivial 5-figure monthly AWS bill, but if my company's AWS costs went to $0/month... it wouldn't move our death date, and it wouldn't change our valuation. This is especially true if there were any loss in developer productivity/feature releases. I would gladly double my AWS bill if I could get features out even 20% faster, though that's not how it works, obviously.
- maximilianburke 4y agoOne big advantage to developing in Rust that I have found over other languages is that you _must_ handle error-type conditions; for example, if something returns an Option or a Result you need to check that it was successful in order to extract the value. 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.
- HideousKojima 4y agoStill won't stop lazy devs just writing _ => () to avoid having to handle it, but at least that's easy to pick up on in a code review.
- jstx1 4y agoYou can still .unwrap() everywhere, it doesn't make for more robust code.
- jeffdn 4y agoThat's pretty easy to catch in code review, or to set up lint rules for.
- pjmlp 4y agoThat property exists in all ML derived languages, which are more productive for backend work with automatic memory management.
- StreamBright 4y agoStarting with Fsharp that has a gazillion libraries (usually pretty good quality ones) and it has much more advanced features from the ML tree than Rust (like |> for example). Rust's error handling might be great for people who are used to exception based error handling but it is a joke compare to railway oriented programming in Fsharp or any ML lang that supports |>.
- MrJohz 4y ago
- zozbot234 4y agoRust has a well designed macro feature that can make it easy to add custom domain-specific syntax for use in Rust programs. We shouldn't underestimate the impact of that as a productivity enhancer, it's getting a lot of use already in Rust web-backend stacks.
- kaba0 4y agoSo does plenty of managed languages. Manual memory management is still a huge detractor from the core business needs, slowing down development time and any future maintenance work (people often forget that it leaks into public APIs, so a memory layout/lifetime change will have to be propagated across code bases)
- deleted 4y ago[deleted]
- nitaigao 4y agoIn my experience with PostgreSQL, using a connection pool and proper indexes can outperform Python or Ruby execution speed by an order of magnitude.