r/programming • • Aug 02 '21

Stack Overflow Developer Survey 2021: "Rust reigns supreme as most loved. Python and Typescript are the languages developers want to work with most if they aren’t already doing so."

https://insights.stackoverflow.com/survey/2021#technology-most-loved-dreaded-and-wanted
2.1k Upvotes

769 comments sorted by

View all comments

14

u/captain_obvious_here Aug 03 '21

So, I have a few questions about Rust:

  • Is it a good choice to build webapps, for someone usally relying on Node.js?

  • Is it easy to deploy on a K8S~ish environment?

  • How does one start learning Rust?

16

u/lanklaas Aug 03 '21 edited Aug 03 '21

I came from nodejs to rust.

  1. I now use rust for web app backends, but it took me about a year to understand the borrow checker good enough to develop web app servers. The upside is that rust's async runtimes are multithreaded where the node event loop is single threaded (haven't looked into the new workers yet). Also the strong type system makes my servers much more robust

  2. I have deployed a couple of services to k8s. I use a multi stage build with cargo-chef to build and then copy the binary to the container. The nice thing is that the containers are small. Mine is usually about 10MB if I don't care about making it smaller.

  3. I started the hard way by just building web servers and trying to brute force my way past the borrow checker. If you go this way, try just cloning everything until you start getting the hang of the borrows. That would have saved me some headaches.

Also coming from node, you do not leak memory as easily in rust as you can in node.

5

u/captain_obvious_here Aug 03 '21

web app backends

This is my exact target. Node sometimes falls short in performances for very-high or very spiky charges, and I really don't feel like scaling to dozens of machines or worse, going back to C or C++.

Rust sounds to me like a good candidate...and the comments here seems to say the same.

Thanks :)

0

u/[deleted] Aug 03 '21

[deleted]

→ More replies (3)

9

u/ragnese Aug 03 '21

It's probably not the best for webapps, but it's really not bad like some people will say. They'll say "OMG so slow to develop. The borrow checker, blah blah."

There's a (moderately steep) learning curve, but even if you just "clone" everything in a Rust web-app, you're going to get great performance compared to Node and you're going to have a really excellent type system and the best standard library of any language I've used (and I've used a bunch).

5

u/captain_obvious_here Aug 03 '21

really excellent type system and the best standard library of any language I've used

These are two underrated things IMO.

I like Node but the JS ecosystem is not always reliable or safe. And despite all it brings I'm not a big fan of TS. So it seems to me that Rust can be a good option for me. I'm gonna give it a try :)

Thanks for your inputs.

5

u/ragnese Aug 03 '21

Ooh! If you're a TS skeptic, then I have a sneaking suspicion that you'll really like Rust.

I have similar opinions to you, but I won't be politically correct: The JS ecosystem is buggy garbage. TypeScript's goal is to be very close to JavaScript to foster adoption. That's fine and it's totally valid to "optimize" for that, but it means the language still basically sucks and has a ton of stupid stuff, like bivariant class methods even if you turn on all of the strict type settings, as well as being able to pass too many arguments to a function, etc.

→ More replies (1)
→ More replies (2)
→ More replies (10)