8 ms·
We are using Rust for backend web development and other things. For us, the safety is the critical reason to choose Rust - particularly the thread-safety. Also
by cjg 5y ago
We are using Rust for backend web development and other things.
For us, the safety is the critical reason to choose Rust - particularly the thread-safety. Also the relatively small memory footprint compared to something like Java. Performance hasn't driven our decision at all - the number of requests per second is very low. It's correctness that matters.
We are a bit unusual because customers have locally deployed servers rather than servers managed by us, so bugs are harder to fix.
We haven't hired any developers specifically for their Rust experience, but have instead trained internally and now have a group of about 10 Rust developers working across a couple of projects. I would say that training like this has been relatively straightforward. One of our hires, a recent graduate, had some existing Rust experience with personal projects, and this was particularly beneficial in helping the team to bootstrap.
The ecosystem is surprisingly mature. Async is probably still shaking out somewhat, but that's moved on hugely in the last couple of years, and we haven't had any particular problems.
Overall the experience has been hugely positive.
The biggest barrier to adoption, in my opinion, is that people are scared of learning Rust because it has a reputation as being difficult. I don't think it's any harder to master than some other major languages such as C++ or Java - although perhaps you have to understand more at the beginning: ownership and borrowing are right in your face.
- brundolf 5y agoWhat web framework do you use? This to me seems like the part that's least-baked at this stage. Iron doesn't support async if I recall correctly, actix supposedly has a complicated mental model and was mired in drama last I checked, and Rocket looks promising but is still in the somewhat-early stages.
- mdtusz 5y agoCheck out tide. It's still very early days for it, but is in my opinion the easiest to use and I'm betting in the long term will win out as the "express" of the rust world. It has very straightforward routing and middleware semantics which covers the majority of the "base" needs for most web server backends.
- cjg 5y agoWe've been using Actix. We evaluated several frameworks and liked the model that Actix has and also its relative maturity (for example documentation / examples). It has been pretty straightforward to work with - including doing things like custom authentication and REST endpoints that dynamically exist. For the drama, I guess you are talking about the situation that used to exist where Actix had hundreds of unsafe blocks. That's pretty much resolved now, with perhaps a handful of performance critical unsafe blocks left.
- ibraheemdev 5y agoYes, Actix today is much different than Actix from a couple years ago. All the unsafe, save a necessary few has been removed, and the architecture switched from an actor model, to a finagle/tower inspired service model.
- zozbot234 5y ago> and the architecture switched from an actor model, to a finagle/tower inspired service model Then they really should think about changing their name, seeing as actix the broader low-level framework is supposed to be all about Actors.
- ibraheemdev 5y agoA name change would have been ideal, but the library was already mature and widely used that it was decided a name change was not worth it.
- iudqnolq 5y agoActix the actor framework is essentially dead at this point, I expect eventually it'll be the other way around: "you should change the name of your actor framework, it's confusing given the name of the web framework"
- therockhead 5y agoAny references to this architecture? The only finagle I aware of is http://twitter.github.io/finagle/ http://twitter.github.io/finagle/ but it's a asynchronous RPC framework and it's not clear to me how it applies to Actix web.
- richardwhiuk 5y agoWe use hyper + tokio directly, with OpenAPI generated API integration.
- beforeolives 5y agoAny reason to choose Rust over Go in your case?
- cjg 5y agoA couple of reasons: 1. We like the thread-safety properties that Rust offers 2. We don't have any Go experience Does Go offer similar guarantees for concurrency?
- steveklabnik 5y agoGo does runtime instrumentation to detect data races, rather than compile time checks.
- pdpi 5y agoGo doesn’t offer the same sort of guarantees as Rust does, but the goroutine/channel model nudges you towards a safe style
- zozbot234 5y agoGo is memory safe for purely sequential code. It's not memory safe to share memory-write access among multiple Go threads. Using CSP idioms only, via Go channels, can preserve memory safety, but is prone to more general race conditions.
- pjmlp 5y agoAlthough better, Rust can only protect against races coming from threads accessing in-memory resources. For races related to external resources, or caused by misuse of OS IPC mechanisms (which is the future thanks Spectre), it offers as much protection as any other language.
- cjpearson 5y agoTraining internally makes a lot of sense, but it's also a huge hurdle and expense if your developers don't already have rust experience. What was the process of proposing rust and getting buy-in like?
- cjg 5y agoWe initially used it on a small project that had the requirement that the chances of a crash / failure should be very low because it would be used as a remote control process for a wider system. We had good success there and so the company was keen to use it in more places. It's now formally "adopt" on our technology roadmap. We've actually bootstrapped relatively easily. We have a some developers who have picked it up quite easily, perhaps with some pairing. We run an hour session every week where all the Rust developers get together to share production code and present on Rust topics. The discussion focusing on Rust production code has been particularly helpful.
- deeviant 5y ago> The biggest barrier to adoption, in my opinion, is that people are scared of learning Rust because it has a reputation as being difficult. I would say the biggest barrier is developers not wanting to jump on yet another "this language will solve all your problems, trust me" train. My experience in my 15 years in software, is that good developers solve problems, not languages or tools.
- zozbot234 5y agoThe languages available today are a vast improvement over what was around 15 years ago. This isn't even all that specific to Rust, even many languages which existed back then have improved massively.
- pjmlp 5y agoMany of which still have some catchup to do regarding Delphi, C++ Builder, Eiffel, Smalltalk and Common Lisp.
- layoutIfNeeded 5y ago>I would say the biggest barrier is developers not wanting to jump on yet another "this language will solve all your problems, trust me" train. Never underestimate what a team of overly enthusiastic junior engineers are capable of :-)
- krapht 5y agoThere's got to be a middle ground somewhere. I've worked in many places where the tech stack fossilizes because the ROE of learning how to use new, more productive tooling is too much effort for the senior devs compared to their existing responsibilities, many of which are non-technical in nature. Meanwhile the junior-intermediate devs spend most of their working hours writing code, so they are extremely sensitive to the 5-10% productivity bump that could be gotten by using {nicer language, better build system, static analysis tooling/sanitizers, ${TOOLING_IMPROVEMENT}. I'm talking real advances in productivity. Imagine working on a C++98 codebase today in 2021 because you're working on a very large industrial product that's been around for decades. It can be demoralizing, like having to write COBOL or FORTRAN.
- CraigJPerry 5y ago>> backend web development >> thread-safety In 2021 what web development stack is making you write threaded code? >> correctness that matters The compilers guarantee end at the edge of your processes address space. You still have the same big problems as everyone else: 1. Are you building the right thing? 2. Does everyone understand the domain adequately to do their job? 3. … 101. Do i have a race condition Except you have a self-inflicted problem - you’re slower than a dev team working in a traditional language (java, go, python, …) and you can’t easily hire talent.
- gpm 5y ago> In 2021 what web development stack is making you write threaded code? Go? I've had thread related bugs in go related to serving our UI. Generally any reasonably efficient stack where you need to pull on more than 1 CPUs worth of resources to quickly serve a request. And most stacks where you need to make multiple requests to other services simultaneously to quickly serve the original request.
- steveklabnik 5y agoMy very first production Rails app involved a C extension to do some heavy processing. Not all web applications are a thin UI over a database table (not that there’s anything wrong with that, mind you…) The framework might not make you but that doesn’t mean your code won’t need such things.
- vips7L 5y agoIsn't that just self inflicted though? You probably wouldn't have had to write C/threaded code if you chose a faster runtime like C#/Java/Go/Kotlin/Scala instead of ruby.
- steveklabnik 5y agoAt the time, Go/Kotlin didn't exist, Scala wasn't established, C# was Windows only, and Java and the JVM more generally were a thing that everyone was running to Ruby and Rails from for lots of reasons. Probably wouldn't have gotten the thing out the door if I had to do it in Java.
- drclau 5y agoCan you share details on what material you used for the internal training?
- cjg 5y agoMost people are happy to teach themselves the basics through some reading of https://doc.rust-lang.org/book/ https://doc.rust-lang.org/book/ then a mixture of pairing, code walkthroughs and short presentations. We will also run a training course next month just based on the Rust book plus some workshop examples.
- tayo42 5y agoRust is really hard to learn though. the compiler errors are hard to read and understand, it's an extremely syntax heavy language. I used to work with someone who regularly contributed to rust, I had some errors on a project that confused him too. The only other times I needed to a book to learn a language was Scala and haskell, both hard to learn languages.
- steveklabnik 5y agoPlease file bugs for hard to understand error messages! We treat them as such. We’d rather have too many reports than not enough.
- tracer4201 5y agoPicking up Rust is not the same as picking up Python or even Java, in my opinion. I started learning Rust and C++ at the same time, coming from a world of Java, Python, and Ruby. If I need to solve a problem in C++, I would much rather write Rust because the compiler actively screams at you when you do bad things. And in my opinion, the challenging part is learning what those bad things are. In other languages, the compiler doesn’t care. You immediately see your program crash or things fail in subtle, hard to reproduce ways later in production. Rust changes that model. I disagree with you on the documentation. I think the Rust documentation is superb. I have yet to see any language give nearly as meaningful information when your code fails to compile. Secondly, Rust front loads and throws issues immediately in your face, as opposed to having you discover problems in your code at runtime. I don’t think that makes Rust difficult - it’s forcing you to think about your choices. And particularly it’s making you think about concepts that perhaps you completely overlooked in other languages - thinking about stack vs heap allocation, moving semantics, shared ownership, etc. If you want to quickly prototype something, Rust isn’t the best language IMO. But if I have a choice between C++ and Rust, I’d go with Rust anyday. If I was starting a new project from scratch and it was more of a web service, I might go with another language over Rust only because I’m more of an expert in Java, Python, etc. and it’s easier to hire developers for those languages than Rust. But I’m biased. Rust has a special place in my heart. It’s the first language I’ve learned in many years where I felt some sense of accomplishment and did not at all feel like “Oh great, another tool that fundamentally doesn’t add value.” For my use cases involving Java and iOS interoperability in a multi threaded environment, nothing else came even close.
- tialaramex 5y ago> I don't think it's any harder to master than some other major languages such as C++ or Java Oh there is just no way it's harder to learn than C++. C++ has the problem that it's all of C (almost everything from C is still in there) plus all the stuff bolted on to achieve C-with-classes when OOP was the new hotness in the 1980s plus then several further evolutions to add major new features, not always in a very consistent way. There is a sub-tribe within C++ that wants a simpler "subset of the superset". They believe C++ could be made into a healthy modern language which is practical to teach as a first language to students and still has excellent performance and hardware compatibility. But if you speak to members of that tribe they invariably feel there's just a few little tweaks to make to the superset first... and I just don't think their dream will ever actually come true. Rust does have a lot of complicated stuff, but almost all of it secretly turns up if you wanted to be good at C++ too. For example, borrowing versus ownership isn't explicit in C++ but it's necessary to understand what's actually going on so that you'll find Stroustrup has actually written proposals for C++ that formalise this exact notion, they just can't be checked for existing C++ as they are in Rust.
- kabdib 5y agoWe can probably all agree that about half of C++ needs to be eliminated or redesigned. We probably can't agree on which half. :-)
- phkahler 5y agoThat's what Rust is. No, not literally.
- verdagon 5y ago> Rust does have a lot of complicated stuff, but almost all of it secretly turns up if you wanted to be good at C++ too. This is mostly true. As FP and Rust have shown us, if you can treat an input data set as immutable, while building up the result data, you have a much easier time. I bring those patterns into my C++, which speaks to your point. I'd offer one exception though: mutability xor aliasability on a per-object basis is something I wouldn't take to my C++ code. It may be the core of Rust, and it's a neat tradeoff that enables some of its other benefits, but the indirect complexity cost is too high, IME. > Oh there is just no way it's harder to learn than C++. I think the jury's still out on this one. C++ has complexity, but has the benefit of a gradual learning curve. You can start with C, slowly add `virtual`, then add templates, then add the STL. Rust has just as much complexity, and forces it all on you at once. Because of that, it is harder to learn. Some people say Rust's rules are intuitive. I have to disagree. These years of working with Rust and teaching Rust to others have made it clear to me: though the basic concepts are simple, the architectural implications and workarounds are not. I'm not saying C++ or Rust is better. But C++ is slightly easier to learn, IMO. I commonly hear "But it's hard to learn how to use C++ safely!" and I generally agree with that. ASan has made things much easier in that regard, but C++ will probably never catch up enough for some use cases.
- ctvo 5y agoWhat a perfect example of developers pushing for technologies they want to learn. A web application stack in the flavor of the month systems language for correctness! My eyes can’t possibly rollback far enough.
- lovasoa 5y agoThis "flavor of the month" language was released 10 years ago and has been the most loved programming language in surveys for several years now. It is also the language of the fastest backend web framework. I don't think rolling one's eyes is the appropriate reaction when someone pushes for it. Depending on your requirements, there are definitely cases when rust is the best choice for a web backend. Especially when moving fast and breaking things is not an option, such as in the author's case.
- throwawaySlu 5y agoI’m at a company where we have tons of Java services. Services scale out horizontally, are fronted with load balancers, and there’s some minimal JVM tuning. Some services have thread pools dedicated to making calls to other services. Aside from that, there isn’t that much multi threaded code that we’ve had to write. Throttling is in use as well. I see a big Rust benefit when you’re writing systems level code or you’re writing once and use the code as a library on Android and iOS. But what type of logic are you writing in your services that requires Rust’s safety guarantees? Or is it that you’ve found you can respond to the same performance metrics (total requests per second) with fewer hosts because there’s no JVM or garbage collection overhead?
- antifa 5y ago> I don't think it's any harder to master than some other major languages such as C++ or Java But this is backend web development, the major languages are more like ruby/php/python/js/java. You might write a C++ extension as an endgame move, but for webdev it's never an opening move.