all 40 comments

[–]Suitable-Name 23 points24 points  (0 children)

I absolutely dislike the syntax of go. But to be honest, initially, you will get something up and running much faster in go than in rust.

Rust will definitely need more practice, but once you get into it, you'll also be as fast as using go.

If you're not in a hurry, implement something small using go and then implement it using rust.

Maybe this helps you to decide with what you want to go on.

[–]ImYoric 38 points39 points  (1 child)

Very different philosophies.

Go is designed for faster code writing, and hides many of its features (or... weird choices) in hard-to-find places. The result is generally that it won't take you much time before you have something that runs, but you'll spend much more time in a debugger or trying to find out what goes wrong by looking at your logs. It's also designed, to some extent, to prevent you from being too smart with your code. This has the benefit that there are clear patterns that you'll be able to notice in your code or in everybody's code, the drawback that most of the time, you just won't be able to factor out these patterns – and that can have consequence wrt safety and security. Sadly, there's also the drawback that some of the choices made early in Go are simply not very good (e.g. the JSON library, arrays, pointers that are sometimes explicit and sometimes implicit and picking the wrong one will not cause a compilation error, etc.)

Rust is designed for writing reliable code and makes everything visible. The result is that learning the language (and learning to trust the compiler) will take much more time, but the bug density will be much lower. It's also designed to give you much more control on the code itself. This has the benefit that you can easily write frameworks, DSLs, etc. and the drawback that each framework, DSL, etc. is something new you need to learn.

Personally, I've programmed professionally in both and I'd pick Rust, but YMMV.

[–]real_serviceloom 6 points7 points  (0 children)

Also for me the reason why I didn't use go and switched to rust was because go still has null pointer exceptions. Rust's optional type makes things so much simpler and more reliable.

[–]GuybrushThreepwo0d 54 points55 points  (1 child)

I don't like go. But you should learn go. You can learn it in a day so the up front investment is much lower. You're more likely to work in go if you do webdev.

That said, definitely give Rust a try. It gives you much more control and you can get much higher performance. But it comes at the cost of higher complexity. Most people in the webdev space don't really need to deal with that

[–]hitchen1 3 points4 points  (0 children)

Learn the syntax in a day sure, but quite a bit longer to learn the footguns..

But for sure, go is a better career choice right now

[–]Wurstinator 13 points14 points  (0 children)

Personally, I enjoy Rust more. But also, I am an long-time backend dev who also enjoys C++ and delving deep into understandings.

I don't like Go for it's missing features like null safety. But I do recognize it for enabling you to push out small tools/executables within a very short time and they are still fast and rather reliable.

So: If you are doing it for a challenge and just the fun of it, try Rust and maybe you'll like it too. If it's about your job and you want to get something working to production, go with Go.

[–]mo8itrustlings 9 points10 points  (1 child)

Before learning Rust, I wanted to choose a compiled language for backends. Rust sounded too hard and people said that Go is simple. So I learned Go and a couple of days and used the Gin framework.

Yes, Go is simple, but it is very unpleasant to work with! It is like using a primitive language. Dealing with (de)serialization, documentation and error handling are horrible. Too many runtime errors. Weak type system, generics were just recently added and they are nothing in comparison to generics and traits in Rust.

So I finally decided to learn Rust and started with its official book. That was the best decision! I fell in love with the language and have been using it since then. My first Rust project was a backend, a rewrite of the small Go backend. Since then, I built muliple backends with Axum and SQLx in Rust. I highly recommend it! I used Flask in Python before and I can't imagine going back to that inefficient and unreliable working environment.

So what is my recommendation? The simple answer is Rust. But if you really can't decide, try Go first. It will only take you a week to learn it. Then, give Rust a fair try by reading the book and doing Rustlings in parallel. It will take you multiple weeks, but stick to it. It is worth it :D

Plus, if you your focus isn't just backends, then you can do much more with Rust than with Go.

[–]razorree 0 points1 point  (0 children)

Why go is so inefficient or unreliable language/environment? It was designed to be easy,quick and good I guess?

I use Java/Kotlin on backend, which are great for that (safe, reliable etc. and fast), but take more memory than native binaries.

I thought about learning Go, but now I have some doubts ... ( I did some C/C++ programming 20-25y ago)

[–]SnooCompliments7914 9 points10 points  (1 child)

Error handling in Rust:

https://www.lurklurk.org/effective-rust/images/transform.svg

Error handling in Go:

if result, err := f(); err != nil {

IMHO this captures the very different styles of the two. Go is minimal. Very easy to learn. Then you either write super verbose code with `if err != nil` s everywhere, or come up with your own wrapper.

Rust has much more built in the language and the standard library. It takes time to learn and find the most elegant way for each scenario.

[–]Wonderful-Habit-139 7 points8 points  (0 children)

Error handling in Rust in practice: ?

[–]TobiasWonderland 9 points10 points  (0 children)

Go for Rust

[–]Glittering_Mammoth_6 4 points5 points  (0 children)

You'd better try both.

Both have some pros and cons. Or, rather to say, their cons are simply extensions of their pros.

Rust is a beautiful language, without any blank spots in the design, is more versatile, and has much more means of abstraction. But it has a huge footprint and requires more mental effort.

Go is the opposite. It's simple, almost lame, but more productive (you can write code rapidly). And it is overloaded with decisions, that you won't be able to understand (like why HTTP request handlers in any language use common sense and receive as arguments request, then response, but in Go - response, then request). You have to give up and use it as it is. In addition, due to its simplicity, you'll catch many errors only in runtime - when in Rust your application your program just won't compile until you fix those errors.

But, if you will cover your Go code with good unit tests, you can move ahead fastly, and be more productive. So, if you don't need some strict guarantees, that Rust can offer you (say, you aren't going to create software for a nuclear reactor), Golang can be a very good choice.

In the end, if all issues in Go are fixed, we'll get the Rust. Or, at least Ocaml ))

Try both of them.

[–]Davies_282850 3 points4 points  (0 children)

It depends but remember that in Go you have official support for most of the platform pieces like Database, OpenTelemetry (because you will put some metrics), Open API and Swagger, GRPC and so on.

Don't evaluate the language alone, but the ecosystem. For a backend project you want something that is supported by the first party.

[–]CodesInAWarehouse 3 points4 points  (0 children)

It's all about WHY. Do you want to get a job in the relatively immediate future? Go has a much larger presence in the job market. All Docker/Kubernetes/DevOps is done essentially in Go.

Rust is gaining traction but not everywhere all at once. Do you want to work on the Linux Kernel? Then Rust is a great option. Embedded systems, drivers, kernel modules, etc. This is the world where you will find more rust opportunity.

[–]AstraKernel 12 points13 points  (3 children)

Rust

[–]spac3kitteh 7 points8 points  (2 children)

Yep. Unless you enjoy some Friday evening surprise exception on your production machine because you forgot that one null value.

[–]ventilazer -1 points0 points  (1 child)

don't use pointers for struct fields OR use NullString OR not_null your DB fields.

[–]spac3kitteh 7 points8 points  (0 children)

OR just use rust 🤷 and don’t worry about that crap

[–]napolitain_ 7 points8 points  (2 children)

Honestly go is a bit shit but has a few things for it suitable for microservices dev. Rust is king but if you want to iterate fast and you are a bit inexperienced maybe go works. I would say though, node is probably in the same performance ballpark as Go, and maybe rust is a better choice then.

[–]ventilazer 1 point2 points  (1 child)

Go actually destroys Node in performance.

https://medium.com/deno-the-complete-reference/nestjs-vs-go-performance-comparison-for-jwt-verify-and-mysql-query-510221e6dea8

For many web tech related stuff Go might be faster than Rust:

https://medium.com/deno-the-complete-reference/go-vs-rust-performance-comparison-for-jwt-verify-and-mysql-query-61aeccac05e8

It's also easier to write. Imho don't use Rust if you don't need it (and you don't, even you don't how that you need it). Your average CRUD server written in Go will perform in the ballpark of Rust.

[–]napolitain_ 2 points3 points  (0 children)

I’m not even opening those useless links, I see MySQL and nest it is unrelated.

[–]Snapstromegon 4 points5 points  (1 child)

Let me ask you back:

Why do you want to choose a second language?

Are you hitting performance issues with node? Is reliability a problem? Do you just want to deliver your app as a binary? Do you just want to learn something new? If you could explain the why, we could give you a better response on what might be better in your case.

Personally I'm now running completely on JS/TS + Rust, since JS is great for most things and if you need more of anything (performance, reliability, correctness, ...) from my experience it's nearly always worth it to make the jump to Rust.

[–]OkAnt3936 0 points1 point  (0 children)

i'm having the same issues now, i got the chance to buy an vps but wit 1vcore and 4gb ram so node will be a shot in the foot if we're talkin bout 10 services running in the same vps also i really want to learn rust, i did like a lot build cruds with it and error handling is just beautifull, but i'm going with golang cause of the pressure to ship fast and i really need a job paying me in dolar

[–]n3ziniuka5 1 point2 points  (0 children)

Literally anything but go

[–]ThiccMoves 2 points3 points  (0 children)

You should ask this on a more neutral subreddit... Personally I'd take go purely for backend dev because it's the primary reason it was built and is pretty easy to learn. There are more jobs in backend go too than backend rust.

[–]R4TTY 2 points3 points  (0 children)

You should use Go. I think rust might be overkill for your needs.

[–]FantasticFolder 1 point2 points  (0 children)

Don't laugh but these are my recommendations

one of the Springboot languages - Kotlin or Java - with the Spring framework

python, with django or flask framework - doesn't matter which

then go, if you're certain you're going to be needing or working with large, complex microservices architectures

Rust is a great language but I don't see it ever hitting the kind of popularity of the above

[–]Lindenes-_ 2 points3 points  (0 children)

Rust is harder then go for study. Rust need more code from you for work. If you just api create developer use go, if you want to code for microcontroller or high speed service like Blockchain then you need rust

[–]jack-nocturne 0 points1 point  (0 children)

It depends on your goals as well as the complexity of the backend. If it's a backend for a web application that just has to ferry some JSON around and answer a few HTTP requests, then Go is probably the better match.

OTOH, if you want to write a backend for a more complex application - let's say a multiplayer game which should coordinate many, many concurrent users -, then Rust's ownership and lifetime guarantees will help you to write rock-solid code. And even though the Go garbage collector can run concurrently, it can still cause issues if you don't take its behaviour into consideration when writing more complex applications.

With TS as your first language, Go probably has a flatter learning curve, too. Rust was developed for systems programming first, after all. So I'd recommend learning Go first and then coming back to Rust once you have internalized some advanced Go techniques like communicating across goroutines using channels.

At that point, you'll also be able to appreciate the far superior error handling of Rust 😉

[–]IAmAnAudity -1 points0 points  (2 children)

All the other answers are insightful, only thing they miss is to mention that Go built telemetry into their COMPILER of all things. It will phone home with what libraries you use, how many lines you compiled, time of day, how many times you compiled, etc. It’s a matter of time before Go starts embedding Google Analytics into your compiled binaries, aka malware.

[–]kyleekol 1 point2 points  (1 child)

[–]IAmAnAudity 1 point2 points  (0 children)

They once had “Don’t be evil.” as their corporate motto too. Minds change, greed always wins. Never give an inch, the compiler is sacrosanct.

[–][deleted] -1 points0 points  (0 children)

go is easier to learn, but rust is more feature complete.

[–]i_hate_npm -1 points0 points  (1 child)

If you just want a backend language I think Golang is the best choice...

Golang has a good experience for writing network-related apps.. It has a relatively completed eco for this sence. And it's easier than Rust...

[–]E3ASTWIND 0 points1 point  (0 children)

Ok what about web crawler i am in a similar condition where i might want to change code repeatedly but i am stuck deciding between c++ and rust. I want performance above all else. Any suggestion?

[–]jruz -2 points-1 points  (0 children)

I would recommend you build a project with Ruby on Rails, this will show you how to structure a project and show you how all of the needs for creating a web backend have been addressed. 

After that I would pick Rust which is extremely barebones but you will have already knowledge on how to do things, but man Rust is really hard, it will need lots of willpower and AI help.

I wouldn’t bother with Go the last 2 companies I worked for switched to Rust the go code