Actually, i am currently backend developer now but from the school years i am really wondered about system programming(e.g. operating system) but i do not have a why to develop.
On the job, i will rewrite a microservice for self-development purposes. As a side effect, i want to get rid of NodeJS applications (no offense, i could not like it). I will provide a Proof of Concept to demonstrate performance and maybe reliability difference.
As i explore, Go is better choice for my use case. For the last time, i want to ask to you: should i write in Go or Rust?
If you say Go, how can i join to Rust world? There may be open source projects but i need your words.
Can Rust completely replace Go for microservices?
Can Go and Rust work together in the same microservices architecture?
Is it expensive to use Rust instead of Go?
Redditers
I'm trying to write some microservices as well as core system modules, on top of which the said microservices will run.
Various posts on the internet suggest using GoLang at least for writing microservices, however, I'm inclined to use Rust as I'm planning to write my system modules in Rust.
If anyone has tried either of these languages, can you please share your experience of using Go / Rust
NOTE: I already know that learning curve for GOLANG is much shorter than Rust
The choice between Go and Rust is all about memory management.
Rust assumes that you believe that GCs are sub-optimal, and provides you with a complete toolset to operate memory effectively.
Go assumes that you believe that GCs are optimal, and provides you with a toolset to manage pointers in a way that the GC can work effectively.
Therefore, you need to do some research on which of these two philosophies strikes your problem in some fundamental way.
For the sake of the example, let's assume that you have a microservice in your fleet that's a very hot spot. It takes lots of connections per second, some of then it just accept the connection and close it doing nothing.
Also, for the sake of the argument, let's assume you're a proficient programmer in both languages - so implementation problems won't hinder performance.
Coming from Rust, most likely you're going to structure your code around the opportunities to allocate and deallocate the memory and connection pointers. Probably you will take the lifetime of the pointer to the functions modifying the connection state. And manage its termination carefully so to avoid loss of time in some blocking call. So, every time you decide to use something, you will also decide if this same something could be deallocated or not (through lifetime management).
In Go, your experience will be dramatically different. Because you don't get to manually deallocate resources, you will be driven to think whether a certain resource is useful in some part of the code. If not, you will not use it, and it will be the GC's job to decide if the given resource is still used (through escape analysis for instance) - one badly written piece of code and GC will take longer to clean it up or the memory will leak. Go makes it very easy to write GC friendly code, so this shouldn't be an issue as long as you don't outpace the GC.
The trade-off is: you can choose to manually manage the memory, which is great if you know what you are doing and you are willing to pay the DX price in Rust; or, you can choose to give away the memory management to GC, lose control of how the memory looks to you, and you get a much easier DX experience.
The last but not the least. Both programming languages have been improving a lot lately. Rust is working out its ergonomic problems - and while I believe it will never be as easy as Go, it will be easy enough.
And Go has been improving a lot its runtime features (namely the GC) and its developer support toolset (observability tools - thanks @rakyll).
It means that any of these two choices are likely safe bets in long term.
Few things:
-
Rust does not have as many libraries as Go for talking to various services for server side things ( think cloud, gRPC, logging / tracing, database ect ...)
-
Same for frameworks
-
Rust needs nightly to build on a lot of recents projects
-
The Go standard lib has more packages to do anything backend related ( serialization, http, db, html template ect ... )
-
Concurrency is honestly better on Go for now, Tokio is not stable and there is no concensus on what to use and it's fairly complicated overall
-
Go tools are good, from the IDE to the various tools to debug, benchmark, profile Go code
-
Keep in mind that Go performance is pretty good, for micro services where IO is most likely the bottleneck you probably don't see that much difference with Rust
On the end if it's just a pet project to learn you should pickup anything you want. tbh I don't think Rust is well suited for micro services where Go is really good at it.