4 ms·
I'm pretty interested in learning rust to build APIs, but I'm already productive with Java and Node/Typescript and wonder if it would be worth it, aside from be
by davnicwil 5y ago
I'm pretty interested in learning rust to build APIs, but I'm already productive with Java and Node/Typescript and wonder if it would be worth it, aside from being interesting.
Anyone up for giving me an elevator pitch that it would be? Or, also interested in confirmation that it wouldn't!
- brundolf 5y agoEither: 1) Latency/peformance/concurrency/server costs or 2) Extreme correctness If neither of these things is a current or anticipated problem for you, it may not be worth it (though you could always do an exploratory project to find out!). Make no mistake: like any engineering decision, for all its advantages it does come with some costs.
- sbeckeriv 5y agoLearn it because you are interested. If nothing else you take back something you learn to another language. The zero2prod has a nice 38 page sample. I'm not sure how zero is for someone who has never written rust.
- jtwebman 5y agoI could see Rust playing a role in microservises where maybe you have a cpu bound service like dealing with logins being in Rust but my guess is it still isn't worth the extra cost to develop and maintain over just scaling that service unless you are getting Facebook/Google level over Java. Still fun to learn though!
- Cyph0n 5y agoRust is performant and helps eliminate entire classes of bugs at compile-time, all while remaining fairly expressive. If none of that interests you, then you probably won’t gain much from learning it, unless you’re curious of course.
- morty_s 5y agoRust requires more of an initial investment than Node/Java, but IMO the ROI is higher or at least more consistent. Others have noted “correctness” as a reason for using Rust, this is accurate. A few reasons I’d give for why it’s easier end more ergonomic to write correct programs in Rust are: * exhaustive pattern matching * Result and Option types * builtin first class unit testing ability * builtin first class documentation ability The enforced exhaustive pattern matching tells you “hey you didn’t cover all cases.” Result and Option types make error handling explicit and ergonomic—the notion that each function can either succeed or fail is supported at the language level (in other languages, it’s up to you to ensure you’ve covered all cases and have thought about what “success” and “failure” mean for each function. Testing is “built right into the language,” it’s frictionless. It’s super easy to write unit tests. You don’t have to canvass and vet a ton of testing frameworks to get going. Documentation is easy, fun, and quick to write. So, now combine all the above with the culture of detailed documentation Rust has and now you’re really thinking through your codebase—you can use writing docs to tighten up the interfaces, seamlessly transition to writing a test that enforces some invariant, leverage “compiler driven development” to rinse and repeat this process. The strongest reason to use Rust is that you’ve detailed the requirements for a piece of code and determine Rust is a better fit than LangX. A weaker, but still valuable reason to use Rust is to experience the discipline and idioms Rust enforces/enables and then take that experience back to your native language (I.e. exhaustive matching, which of used in certain ways can be a kind of “proof by cases” that your code does exactly what you expect, then you can easily inspect what you expect via tests).