r/Backend • u/Opposite-House3656 • 2d ago
Rust vs Go for web app backend
In my company having node js as backend facing issues like vulnerability update each week it making hard to maintain prod to update. So how in your companies handling this difficulty.
Planned to migrate from node to go. What does your suggestion on this. Rust is taking entire trend now. Is Rust is better then go for web apps?
37
Upvotes
23
u/sreekanth850 2d ago edited 2d ago
First don't pick a language based on what others say without knowing your product. Check how is the ecosystem suitability. eg: if you are building an devops orchestration platform Obviously Go have several advantage with rich ecosystem. Check the maturity of library you need in your project and their coverage. in majority of use cases performance difference will not be a concern for real world between Go and rust. Unless you are working on a high level close to metal product.
55
u/ray591 2d ago
Just use Go bro, don't overthink it.
10
u/Any-Appointment-814 2d ago
Honestly I'd be careful rewriting a working backend just because of the weekly vuln updates, Go has CVEs too and you'll still be patching, just fewer packages. Most of that pain in Node comes from a huge dependency tree, so I'd first check what you actually pull in, drop the stuff you barely use, and let Dependabot or Renovate open the update PRs with tests running so it becomes a boring merge instead of a fire drill. If you still want to move after that, I'd pick Go over Rust for a normal web app and migrate one piece at a time, a big bang rewrite is how teams lose a year.
5
u/jbergens 1d ago
I haven't looked at statistics recently but C# and Java are still common at companies and probably even more common than Go.
I would probably evaluate C# also but would prefer Go to Rust for web things.
8
u/FalseRegister 2d ago
I actually see Go taking more trend than Rust these days. Rust has been used more for other things. Go was specifically made for web backends / systems, so people are choosing that. Plus it is a plain, simple language, so it does well with AI.
7
u/ebykka 2d ago
It doesn't matter whether it's Rust, Go, Java or C#. Any strictly typed, compiled language will be better than Node.js.
I recommend taking a look at C# because the syntax is similar to TypeScript, and I guess your team is familiar with that, so you will be able to transfer many of your writing habits and knowledge there.
3
u/IncomeOk7237 1d ago
Honestly the weekly dependency churn is mostly a property of how big the npm tree is, not Node itself. Before rewriting I'd check how many of those advisories actually hit code you run. npm audit is noisy, a lot of it is dev deps or some ReDoS in a CLI tool nobody calls in prod.
If you do move, Go is the boring safe pick for a web backend. net/http in the stdlib is good enough that you can get away with a router and a db driver, so the dependency list stays small. govulncheck is nice too because it only flags vulns in functions you actually call, so way less noise than npm audit.
Rust is great but you pay in compile times and the async learning curve, and a normal axum + tokio + sqlx app still pulls in well over a hundred crates. So it doesn't really fix the "too many deps to babysit" problem on its own.
3
u/old-and-very-bald 1d ago
Rust is really amazing with Axum + sqlx. You will get small very powerful binaries, without any kind of GC breaks. Only downside to rust really is compilation times
5
u/BenchEmbarrassed7316 2d ago edited 2d ago
Rust vs go - it's more of a philosophical question, but it was quite relevant some 5 to 10 years ago: Rust is a "smart" language that sought to solve complex problems in an intelligent and elegant way, and, by doing so, achieve efficiency. go, on the other hand, is a "dumb" language that attempted to tackle complex problems head-on, in a naive and repetitive manner. However, with the addition of generics (including bounds in recent versions), iterators, and other features, go is no longer that simple language; it has effectively become a poor, inconsistent, less reliable, and less productive copy of Rust.
go is very error prone due to stupid decisions like null, default values and a bunch of other hidden guns. Rust is the opposite, it just doesn't allow you to write bad code.
Here is a minimal code example:
https://go.dev/play/p/JDHv8Kxo89H
It prints:
A similar operation on Rust will return an error, and will not implicitly, in the best Js traditions, convert null to 0. So go developers just have to learn this and 100 other rules and special cases. So go's simplicity is a myth.
Rust:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=a9add2d84b93651687435c8152b6c7ef
Prints:
2
u/Eye_NeO 1d ago
Use go if you like simplicity. You will still have DIY some things. You can easily start off by using default mux or use any router like Gin, Fiber or Echo. Do keep in mind that input binding in gin will require more boileplate compared to Fiber as fiber can bind from all sources in one call while Gin cannot do that.
Use C# if you want very rich prebuilt ecosystem. You got ASP.NET with MVC style controllers and functional controllers using MinimalAPI. You get DI out of the box, Data Annotation and FluentAPI for validations and EfCore as ORM for Db layer
2
u/No_Tomato3810 1d ago
Go, some pains you'll face, if you're used to orms, Go or Rust will be very painful, things like middleware and types(openapi), will be painful as well. You'll have to implement yhis both on the backend and frontend. unless your company was using node js as an api, then this will be nothing new.
But if it's a sacrifice you're willing to take, then Go will be perfect.
Rust is nice, but you'll spend most of the time fighting the language, not being productive...plus everything else I just mentioned above.
I'd also put C# ASP.NET core on top of the list as the most viable option, it's fast asf, battle tested, lots of very well maintained packages, which you won't find in Go or Rust, most packages from Go or Rust are either very new, or haven't been touched for the past 1 year, so you'd probably have to build most of things by yourself/team. All that said, avoid the trend train, be your own man/company.
Jump off the high dive! Pee into the wind my friend.
2
u/ledatherockband_ 1d ago
For backend? Golang.
Only reason I (read: Claude) used rust so is that I would incur less cloud spend because Python is a resource hog and the packages I needed were in Rust not Go.
4
u/Beagles_Are_God 1d ago
I don’t find Rust as something made for Backend development. Yeah it is possible but it’s a lot of unnecessary memory and system management for a backend.
Go is perfectly capable of this, not only that, it was made for this, however a lot of things you have to make from scratch, like auth; Good thing about go is that it has pretty much just one way of doing the same thing so the solution is always the good one, however it can be a little verbose, or more than verbose, tedious and repetitive.
If you really need something Rust is only capable of doing (i doubt), then you can always make a separate service with it.
1
u/Scyth3 1d ago
They're both great. Go is my "goto" for this kind of stuff if speed to market matters. Rust is what I currently use if I have a few extra weeks to shake out async behavior.
I've written golang that handles petabytes of data parsing/movement a day, and rust services that backend entire tablet infrastructure. It also depends what your team is most comfortable with.
1
u/Nearby-Pen-4624 1d ago
Honestly based on your req you had to go and don't take anything as good
1
u/bart_88s 1d ago
Just use whichever you enjoy more. I doesn’t really matter.
1
u/MyExclusiveUsername 1d ago
I'd stay on Node. There's always Bun if Node isn't your thing. On top of that, AOT numbers aren't far off from Go, and at high load you won't notice a difference anyway.
1
u/mcfriendsy 1d ago
The dependency hell can quickly become a pain point. In fact, that's the whole idea behind Zuri (https://github.com/zuri-lang/zuri, formerly Blade). Though, I won't say it's generally production ready yet. I mean there are a couple of enterprise production apps running on it even for fintech products serving thousands of users, but that's because the maintainer (me) is also actively involved in those projects. Either way, worth checking out.
1
u/frenzied-berserk 1d ago
Go is the best choice for you. Rust has everything to build a modern backend, but the paradigm and learning curve may slow you down.
1
u/greyeye77 1d ago
go is not vulnerability free, but does few things to protect from many supply chain attacks. And you often can run everything on the distroless base image that comes with nothing. This reduces the `***2shell` attack vectors and related vulnerabilities.
also, most underappreciated factor with go is that I've never had issue rebuilding old code. (try doing that with rubygem, npm, pypi) as often it just download the source code and build from github. (almost 0 need for a platform specific pre-built binaries)
build/test runs in less than a min for the most of the time, and testing is built in to the eco system (no need for addon tests like Jest)
I still value reading code and writing a bit of Go, and it's the most `human readable` code base, (in par with maybe Python)
1
u/Temporary_Practice_2 1d ago
What exactly are you facing with Node? Just curious
1
u/Amazing-Mirror-3076 1d ago
We are moving everything to rust - it's the best choice for the ai age where DX is now irrelevant.
1
u/SoupAccording8095 22h ago
Choose go, it's exactly what you are looking for. It has the most feature complete, batteries included standard library http package.
This is particularly helpful for your use case, reducing CVEs and easy updates and maintenance.
1
u/Due_Warthog749 13h ago
I'd say Go for API/microservices, but Rust will give you more control, more speed but take a lot longer to implement/learn unless you're using AI 100% of the time. In that case, probably Rust for its bare metal access vs Go.
1
u/digihmong 8h ago
Use both, each are great at their own things and work well together. AI solved the learning curve.
1
u/arivictor 7h ago
Which is better: do you like writing Go or do you like writing Rust?
Performance is a moot point unless you're one of the rare few companies where you are already hyper-optimising your code to squeeze the last 2% out.
For me, for readability and general quality of life: Go
1
u/leon_pylo 3h ago
I'd go with what you and your team knows best, even if you generate most of the code with AI, having a tech stack you are not even able to read might go wrong and I'd not do it for anything important or business relevant.
3
u/nightm4re1911 1d ago
As someone whos used PHP all his life and im old as fuck - use Go
1
u/UhLittleLessDum 13h ago
Rust. If vulnerabilities are your concern Go would be an insane decision.
2
u/tenken01 1d ago
Java
0
u/RoboErectus 2d ago
I have never really liked go at all.
There are some great frameworks for rust now that make it a real contender for backend development.
The future is rust imo.
1
u/wrd83 1d ago
perhaps reduced dependencies could help you?
but if you come from node I'd rather have go, and I don't think you'll get the benefits of rust unless you really commit to it. By this I mean seriously thinking about performance and training your staff to do so.
Go I'd say is easier to manage, but it has also issues with go routines and channels that you have to own up to.
1
u/every1sg12themovies 1d ago
My two cents. Rust is harder to learn and get your head around if you didn't program in c before. Also go has much much bigger ecosystem.
Personally tried both but stuck with rust (in a good mood at haha). Also ask the team what would they prefer.
1
u/n9iels 1d ago
Use what works for your company. If no one knows Rust for example it doesn't make sense to choose that. Do keep in mind tough that patching your application was already a common task. Go, Rust, PHP, Python, no matter what you use the dependencies need updates. Nowdays with AI this will be even more commen. Migrating to a particular language will not change this.
1
u/antoine235 1d ago
Go it's a no brainer. Performance and dev/agent exp out of the box. Yes, the right rust code will outperform go (and most other languages out there) when facing masive pressure, but seriously, do you think your project will reach such critical levels?
1
u/monta_gia 1d ago
Research before doing migration. The simplest way migrating part by part of existing backend
Don’t follow trend it just pain your ass when you write code you don’t understand.
1
u/migueln6 1d ago
None, Laravel with PHP, maybe c# with .net core but Laravel the king.
1
u/One_Fuel_4147 1d ago
go with std http router, sqlc, goose, task file.
1
u/BDer82 1d ago
pick the language you are most comfortable in, both will do nearly anything you want, both will do most of want you'll need and be very straight forward about it, both will have areas where you will go arseovertit to make something work and end up being very unhappy about doing it but, it'll work.
neither language is king or queen or even worthy of the hyper drooling rabbit dog stance some people take about them.
Pick one, neither are perfect, but can accomplish nearly everything.
1
u/vips7L 1d ago
Rust is the wrong choice for web services.
1
u/Amilektrevitrioelis 20h ago edited 20h ago
Yes, Rust is better. Whatever libraries that are now missing, will be ported over very soon.
Rust didn't get used before for web backends for 3 main reasons:
- Slower development time.
- Higher skill needed to use it effectively
- Missing/immature libraries.
The first two have been solved by agentic coding. The 3rd one is being solved right now. The business reasons not to use it disappeared.
We have the potential to finally have well-performing backends and other stuff.
Just use Rust, forget the toy language that is Go.
1
u/Codeplex1 1d ago
Maintenance would be required for any backend: node, go, or rust.
For web, always go with node.js, because it's built for the web from the ground up. Other engines needs a lot of patching to work as web frameworks, and their code is verbose with a lot of maintenance issues.
0
u/NoName-NNN 2d ago edited 2d ago
My side project: Node.js(TS)->Bun(TS)->Go->Java。My experience:
0
u/zarlo5899 2d ago
my gotos for backends is C# and Go
0
u/KariKariKrigsmann 1d ago
Go for C#, it’s easier if you already use Typescript.
-1
u/Nearby-Property-8163 1d ago
Want to do web apps and don’t think about php?
Highly inappropriate.
Php is the language that was created specifically for web use and development and has a lot of frameworks and community support.
Would you also call for a plumber to fix doors for you?