12 ms·
Zero to Production in Rust
- rattray 5y agoThis looks really great. £35 Individual, £100 Team, £600 Company, seems like fair/straightforward pricing for a team that has members who know some Rust but haven't built out a production API with it yet. I wish every tech stack had a book like this, and I think it'll be particularly valuable for an exciting new language with a learning curve like Rust. I will note, though, that I'm currently consulting on a team that's transitioning away from Rust for their startup's GraphQL backend because they found it too slow/difficult to onboard more junior engineers to the language. Personally I find the Rust code pretty great, but the learning curve (and perhaps even talent cliff) is something to keep in mind if you're considering Rust for a standard web api use-case. TypeScript is probably a more appropriate choice for most situations – still a rich, powerful type system, great performance, and much faster compilation times (and thus iteration speeds) and much, much easier to find engineers who will be productive within a month on your codebase. EDIT: To be clear, I still consider myself a fan of Rust, and am keen to have an excuse to use it.
- ddorian43 5y agoWouldn't Golang be the TypeScript here as alternative to Rust ?
- rattray 5y agoWhy? Golang has a much less advanced type system, comparable runtime performance, a smaller developer community, and a smaller package ecosystem. Plus, if you're building a backend for a webapp, TS allows your engineers to build full-stack features in the same language, avoiding context-switching, code duplication, and other overhead.
- sriram_malhar 5y agoI accept all your points, but comparable runtime performance? That's the only reason that people away from node/ruby/python towards gaoling.
- k__ 5y agoAs far as I know, after Node.js/V8 the only reasonable performance gain comes from switching to Rust/C/C++. Everything else is just a few % faster, not a magnitude.
- hellbanTHIS 5y agoI recently rewrote a computation-heavy Typescript program in Go and what once took 12 hours can now be done in about 3 minutes - there was also some trickery involved running things in parallel but Go made that possible, trying to do that in JS just froze my computer. Plus it’s a binary I can drop anywhere, will always be backwards compatible, no updated dependency is going to break it, I’m a fan of Go.
- rattray 5y agoTurns out I hadn't heard of go's fiber framework, which performs impressively on Techempower's composite benchmarks (just behind the top ten dominated by C++, Rust, and .NET Core, and barely ahead of Java). Other than Fiber, the techempower composite framework benchmark[0] ranks gin (go), nodejs, clevergo, and fastify (node) one after the other, all scoring right around 1600. To be fair, Express is half that good at ~800, but upgrading from express to fastify should be fairly straightforward for those seeking better performance; the much newer fastify has a similar (often compatible) API. For comparison, Python's fastapi is only 1200, and Django/Rails a mere 250, so lumping Node in with Python and Ruby doesn't make much sense; it'll often perform an order of magnitude better. For computation-heavy workloads, multiprocessing with Node remains a challenge; Go's a more clear winner there. [0] https://www.techempower.com/benchmarks/#section=data-r20&hw=ph&test=composite https://www.techempower.com/benchmarks/#section=data-r20&hw=...
- Fiahil 5y ago"difficult to onboard", yeah why not if your juniors are not self learning. But "too slow"? What?! Edit: oh I get it, "too slow" as in "compilation time". I guess they really needed excuses to move back to another language.
- autarch 5y agoI think "too slow" is "too slow to onboard juniors", not "too slow in terms of performance".
- rattray 5y agoCorrect – it took about 6 months for people to become fully productive in Rust, which matches what I've heard elsewhere. Though I will note that the Rust compilation times were also far more painful than I'd expected – even the tiny (~5k sloc) app at hand would take what felt like a minute to recompute the red squigglies in my editor. TS felt slow if it took 5-15sec, and Sorbet (for Ruby) was usually <3sec IIRC, so a minute+ was pretty bad. Rust was in the realm of "just don't use this language if you have ADHD" since you really can't make progress without the compiler's exacting approval, and I'd constantly get distracted while waiting.
- jkelleyrtp 5y agoMake sure you're not using `cargo build` to check your project. `cargo check` (the thing that makes your squiggles red) has never once taken me a minute to complete. RLS (the default LSP for rust uses `cargo build` - definitely switch to Rust-Analyzer (the soon-to-be default). I just ran `cargo check` on my workspace (10 crates, about 5k LoC) and it took 3 seconds.
- rattray 5y agoMy mistake! Replacing RLS with Rust-Analyzer, it now takes 20-30s to incrementally check a trivial change to some core model code (compared to ~90s with RLS), though now rust-analyzer gives me an unrelated error which I assume may be the result of using a different rustup/cargo binary or something – so I'm back to RLS. Oh well. It looks like RLS and Rust-Analyzer are working on unifying their code, so I'm sure this will get better in the not-too-distant future.
- cultofmetatron 5y agoat my startup, we built a graphql server in elixir and its been great. very easy to onboard contractors and the language is very straightforward. https://absinthe-graphql.org/ https://absinthe-graphql.org/ The performance has been excellent compared to similar offerings in django and rails while having better dev productivity than the equivalent nodejs libraries.
- cjg 5y agoI have been involved in training several "junior" devs in Rust and I would say that it's more about their ability as a developer rather than them being junior. Developers who could get by professionally in Python, but were not particularly good, have struggled with Rust. However, we have several developers who joined us directly from their undergraduate degrees who have picked up Rust extremely easily.
- alpaca128 5y ago> TypeScript is probably a more appropriate choice for most situations – still a rich, powerful type system, great performance, and much faster compilation times Compared to Rust's normal debug builds Typescript does not have any noteworthy compilation speed advantage in my experience. In fact I find incremental Rust builds very similar if not faster in some cases (of course there are extreme exceptions both ways; I've used a library that added 40 seconds to every Rust build, but also frameworks that didn't make a noticeable difference after the first build). Meanwhile the quality of TypeScript error messages is much worse. Also sometimes debugging gets confusing because TypeScript has a couple blind spots and in the end it still turns into JS with all its quirks. I find Rust's type checker significantly more precise and comprehensive. On the other hand TypeScript doesn't (need to) care about things like pointer ownership, so often there's much less to worry about.
- genuine_smiles 5y agoWe can cheat Typescript builds by using a different tool to strip the types, and generate type errors on a different thread. The type errors can be terribly slow, and the build times quite fast.
- cjpearson 5y agoSo I've just tinkered around a bit in Rust, and I'm not intimately familiar with the language. My experience has been pretty good, but I don't see how it's a good fit for the web domain. At least not the enterprisey, CRUD, business apps I'm used to building. I'd be curious to hear from people who have been using Rust for their web backends, though. Beyond the classic selling points of speed and safety, what benefits have you found that apply to web development? Have you had any issues with the ecosystem or finding developers?
- nine_zeros 5y agoIt helps in RDD (resume driven development)
- jkelleyrtp 5y agoThe DB space for Rust is a bit young, though there are several good projects like sqlx making it much more pleasant. Rust shares many of the benefits of Go: - statically linked binaries for ease of deployment - good concurrency - builtin testing framework But it's a much sharper tool than Go: - Really great error handling with Result/Option and the ? marker - Like, really really good error handling, esp compared to Go - Very pleasant logging and tracing - Serde is fantastic at automatically serializing/deserializing datastructures - Generics make Map/Reduce/Filter really easy and readable - Really good project management through modules/Cargo.toml - Crates.io is like NPM - really discoverable and easy to upload (with its goods and bads) - FFI with Swift, C, C++, Node, etc to share code everywhere - Builtin documentation - Builtin benchmarking - Powerful hygienic and non-hygienic macros There's a lot more. I would say people choose Rust over other web frameworks not because of the language, but the emphasis on great tooling. Being able to test, document, benchmark, deploy, package, with a language that feels like a child between Go, JavaScript, and C++ is very attractive. Plus, it's fast - like really fast - and it's really obvious where optimizations can be made when the time comes. I've worked a decent amount with Go, but I'm also frustrated with the size of projects balloon. When I compare my Rust and Go code, the Rust code ends up being much smaller (LoC) and much more dense/terse. I've been working with it for a few years now, and I'm 100% willing to trade some complexity when doing Advanced Stuff (tm) for the 1st-class tooling. I hate having to decide which testing/documentation/building/benchmark/etc framework to use in other languages. I just want to build, not futz around with Jest/Babel/Webpack/Poetry/PyEnv/Opam/CMAKE etc. If you're looking into using Rust for web, I recommend https://github.com/http-rs/tide https://github.com/http-rs/tide - it's the most pleasant web framework I've ever used.
- wokwokwok 5y agoIs it cool now to just link to landing pages where you sell things now? Am I missing something? Why the hell are people upvoting a “buy now with discount code” page?
- ddorian43 5y agoHopefully we can have some conversation about the ecosystem and state of rust for backend webapps.
- wokwokwok 5y agoYou can link to any kind of meaningful content to do with rust and do that. This is using HN as an ad platform.
- steveklabnik 5y agoHN pretty much originally existed as way to advertise ycombinator. Entrepreneurs make up a huge HN demographic. Marketing, sales, and advertising is a regular topic. “Show HN” is a special tag for certain kinds of marketing to HN users. Doesn’t seem out of place to me, to be honest.
- rob74 5y agoBecause Rust?
- davidwparker 5y agoI upvoted it because: 1. HN, in my experience, is an extension of ycombinator. Since it's this guy's entrepreneurial thing, I think that's relevant. 2. I'm interested in Rust, though I've never used it. 3. I'm the target demographic for this. edit: formatting
- darthrupert 5y ago> I'm interested in Rust, though I've never used it. Yep, that's how most people seem to feel about it before they try it.
- sbeckeriv 5y agoI have been writing rust for personal projects for years. I love how the book structures the project and it is test driven. I will be using it as an example when I do projects moving forward. I like that it is one complete project a lot as well. It is off topic for the book but I want to add a yew.rs frontend. I call it the PAY stack (Postgres actix and yew).
- davnicwil 5y agoI'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).
- KingOfCoders 5y agoLove that book!
- CraigJPerry 5y agoI don’t want to shit on anyone’s hard work because this does look cool and useful if the language was Python, Java, Go, C#, … Using a systems language where it’s not required is just burning time and money.
- steveklabnik 5y agoAs I said above, it may actually be the opposite. Depends on many factors, but the larger you scale, the less true what you’ve said is.
- lstamour 5y agoThere was a time when Go was considered a “systems language” only, and very little web development was done with it. Same with Node.js V8, which initially had very little going for it. Every language starts without much of an ecosystem. If folks find Rust to be beneficial, we’ll see that change for Rust too.
- Animats 5y agoAd for a £35 book. "Zero To Production will focus on the challenges of writing Cloud-native applications in a team of four or five engineers with different levels of experience and proficiency." It's useful for that. It's not about how to program in Rust. It's about how to set up a production web application in Rust. This is more of a tooling problem.
- lstamour 5y agoIf you visit https://www.lpalmieri.com/ https://www.lpalmieri.com/ you can read the chapters before buying and supporting the author.
- raspo 5y agoI just read through the email newsletter sample chapter, this seems really well done so far! I really appreciate how the author keeps a pragmatic approach, by copy-pasting code snippets found on the libraries docs and, at the same time, goes into details and explains every little line of code, without overwhelming the reader. Just a quick (design) feedback: I personally felt like those blue boxes used for pull quotes draw a little too much attention. I wasn’t sure “how” I was supposed to read them at first: is this a “quick tip” box? is this something important I should pay extra attention to?
- PragmaticPulp 5y agoI’d encourage anyone considering Rust development to simply dive in and use freely available resources online. When I was first trialing Rust I didn’t feel like I was missing anything by using free resources. The Rust ecosystem is moving fast enough that a book might only be relevant for a short while anyway. You’d end up having to read the latest documentation to use updated packages anyway. This may not be a bad way to spend a book stipend if you have to buy something, but don’t internet the existence of this book as an indication that it’s necessary to penetrate the world of Rust backend services.
- paulgb 5y agoI self-taught myself the core parts of Rust, but when I recently decided that I wanted to do Rust full time, books like this (including this one, in fact) easily paid for themselves in terms of time saved even for a heavily discounted value of my time.
- GiorgioG 5y agoI bought this book a couple of months ago - I think it’s well put together and practical as someone familiar with backend development (.NET) looking to learn how to do it in Rust. Yes there’s free resources to learn anything, but most online tutorials are not in-depth. It’s up to you if prefer to piece together your knowledge from various sources or if you want to take a deep dive. There is no single right way to do it.
- PragmaticPulp 5y agoFor what it's worth, I've been pleasantly surprised at the amount of free and open-source material supporting Rust development. There are several books covering Rust web apps (including this one) but frankly I never felt limited by the freely available materials.
- AtNightWeCode 5y agoI evaluated Rust for web development some time ago and was surprised that it was even worse than Go. I mean there are so many good tech stacks for web development. Why choose language over frameworks.
- onelastjob 5y agoI'm currently looking for Rust devs that are interested in joining a side project that uses Rust for the back-end of a web app. The project involves working with Solana (a smart contract cryptocurrency coded in Rust). If interested, email me at rusted[at]fastmail[dot]com
- _Kobo_2207_ 5y agoRust has its strength and weaknesses. Using Rust for network-latency bounded applications (e.g. web applications) simply means you're not using the right tool for the job.
- vldr 5y agoFor me the hard part about Rust is the borrowing, lifetimes stuff and this book doesn't really seem to address these. For me that means you won't get to Production (at least not starting from Zero) since these are concept that make Rust truely different from other language and without properly grasping those, you will run into hard to understand errors and code that won't compile. It also seriously affects how you structure your code in general. There are plenty resources that do properly explain these concepts but in the end you will just need to get it in your system, which is what I'm currently struggling with. The flow of code as I'm used to writing in C, C++, Python or Go simply won't work for Rust