2023-12-01
2518
#go#rust
Michiel Mulders
25770
Dec 1, 2023 â‹… 8 min read

When to use Rust and when to use Go

Michiel Mulders Michiel loves the Node.js and Go programming languages. A backend/core blockchain developer and avid writer, he's very passionate about blockchain technology.

Recent posts:

Nx Adoption Guide: Overview, Examples, And Alternatives

Nx adoption guide: Overview, examples, and alternatives

Let’s explore Nx features, use cases, alternatives, and more to help you assess whether it’s the right tool for your needs.

Andrew Evans
Mar 28, 2024 â‹… 9 min read
Understanding Security In React Native Applications

Understanding security in React Native applications

Explore the various security threats facing React Native mobile applications and how to mitigate them.

Wisdom Ekpotu
Mar 27, 2024 â‹… 10 min read
Warp Adoption Guide: Overview, Examples, And Alternatives

warp adoption guide: Overview, examples, and alternatives

The warp web framework for Rust offers many enticing features. Let’s see when and why you should consider using warp in your projects.

Ukeje Goodness
Mar 26, 2024 â‹… 8 min read
Integrating Next Js And Signalr For Enhanced Real Time Web App Capabilities

Integrating Next.js and SignalR to build real-time web apps

In this tutorial, you’ll learn how to integrate Next.js and SignalR to build an enhanced real-time web application.

Clara Ekekenta
Mar 25, 2024 â‹… 8 min read
View all posts

12 Replies to "When to use Rust and when to use Go"

  1. Your Rust thread example doesn’t spin up 10 threads, which I think was intended. It just runs a for loop in a single thread

  2. You didn’t compare Go very well in the last half of the post, in my opinion. You focused very heavily on how Rust approaches those topics instead of mentioning how Go handles them.

    A pet peeve of mine is also “Golang” is not the name of the language as they state on the site due to the confusion of registering Golang[.]org.

  3. What do you mean by the workd “subprocess” when talking about Go? Do you mean to say that the application will literally fork(…) off a child process? I’ll admit that I’ve never used Go, but that was not my impression of its architecture–I didn’t think that there was even a one-to-one correspondence of invoked goroutines to threads, but instead that it had an M-to-N threading model based on Go’s own implementation of pre-emption inside of its runtime. I would appreciate clarification.

  4. Hi Matt, thanks for your comment and honesty!

    The goal of this post is to provide a high-level overview between both languages for developers who need to decide between both languages. I’ve included some code snippets but don’t want to go into detail for each element. A great resource for looking up all discussed elements in this post is https://gobyexample.com/ 🙌

    Besides that, we’ve updated the post’s title from “Golang” to “Go”. Thanks for notifying us about this! 🙂

  5. Hi Ian, no worries, let me first clarify Goroutines using Go’s documentation (http://golang.org/doc/effective_go.html#goroutines).

    > They’re called goroutines because the existing terms—threads, coroutines, processes, and so on—convey inaccurate connotations. A goroutine has a simple model: it is a function executing concurrently with other goroutines in the same address space. It is lightweight, costing little more than the allocation of stack space. And the stacks start small, so they are cheap, and grow by allocating (and freeing) heap storage as required.

    > Goroutines are multiplexed onto multiple OS threads so if one should block, such as while waiting for I/O, others continue to run. Their design hides many of the complexities of thread creation and management.

    In short, Go multiplexes multiple goroutines into threads. So you are right about to M-to-N threading model. I’ve used the word “subprocess” here losely to make the concept more clear. It’s not 100% accurate. If this is confusing, feel free to ping me @michielmulders -> We want to avoid confusion! 🙂

  6. I think your language got confused between concurrency and parallelism while talking about Go. Go concurrency doesn’t spawn tasks across multiple CPUs, it maximises the single CPU utilisation by running sub processes concurrently (not in parallel)

  7. I get an error on line 7:
    thread::spawn(|| {

    error[E0373]: closure may outlive the current function, but it borrows `i`, which is owned by the current function

    Fortunately the Rust compiler tells me how to fix it:

    help: to force the closure to take ownership of `i` (and any other referenced variables), use the `move` keyword
    thread::spawn(move || {

Leave a Reply