# Go Vs Rust

**URL:** <https://internals.rust-lang.org/t/go-vs-rust/2842>\
**Category:** Uncategorized\
**Created:** [October 27, 2015, 9:09pm UTC](https://internals.rust-lang.org/t/go-vs-rust/2842 "2015-10-27T21:09:03Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![ak2015](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@ak2015](https://internals.rust-lang.org/u/ak2015)\
**Post date:** [October 27, 2015, 9:09pm UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/1 "2015-10-27T21:09:03Z")

</div>

Hi:

I have been coding in Go, and recently I heard about Rust. As I see Go also has almost same features as Rust like - functional language constructs, great concurrent primitives, optional GC, easy to use, systems language.

Hence would like to understand why would one choose Rust over Go. Please help me understand.

Thanks.

---

<div class="post-metadata">

**Author:** ![retep998](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/retep998/32/729_2.png) [@retep998](https://internals.rust-lang.org/u/retep998)\
**Post date:** [October 27, 2015, 9:32pm UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/2 "2015-10-27T21:32:56Z")

</div>

1. Rust is more of an actual systems language than Go. So it actually doesn’t use or need a GC at all while Go depends on a GC to clean up the garbage that gets generated. People have been able to successfully use Rust in a variety of embedded environments and in kernels, which Go is simply not suited for at all.
2. Rust is a much safer language. Things like not having null pointers, and achieving memory safety without a GC are things that Rust can do that Go does not do.
3. Sugar for user-defined types. You can define your own custom containers and have operators like [] indexing on them, unlike Go which only allows operators for the built in types. Also various operators for arithmetic stuff.
4. Things like generics and traits to allow type-safe and efficient code that takes a variety of types. Go meanwhile just has interfaces which have no compile time checks. If you write a “generic” container in Go there’s nothing stopping you from inserting something of the wrong type.

---

<div class="post-metadata">

**Author:** ![burntsushi](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/burntsushi/32/279_2.png) [@burntsushi](https://internals.rust-lang.org/u/burntsushi)\
**Post date:** [October 27, 2015, 9:51pm UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/3 "2015-10-27T21:51:54Z")

</div>

> [@retep998](#):
>
> Go meanwhile just has interfaces which have no compile time checks.

I think you mean `interface{}` has no compile time checks. Certainly, non-empty interfaces do. (The compiler will ensure that a type `T` for interface `I` actually satisfies interface `I`. All types satisfy `interface{}`.) This means that Go does indeed have type safe polymorphism (structural subtyping). You will sacrifice static dispatch in the process, though.

---

<div class="post-metadata">

**Author:** ![Gankra](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/gankra/32/6002_2.png) [@Gankra](https://internals.rust-lang.org/u/Gankra)\
**Post date:** [October 27, 2015, 10:45pm UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/4 "2015-10-27T22:45:46Z")

</div>

Although Go’s polymorphism solution is arguably a bit less type-safe because it’s duck-typed. iirc this led to some frustating results when their std lib started to optimistically up(down?)cast interfaces for specialization purposes. Essentially checking if there also happened to be another method on the input with the right name and calling that.

Yay, tradeoffs!

---

<div class="post-metadata">

**Author:** ![mdinger](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@mdinger](https://internals.rust-lang.org/u/mdinger)\
**Post date:** [October 28, 2015, 5:02am UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/5 "2015-10-28T05:02:12Z")

</div>

This was also discussed recently on [reddit](https://www.reddit.com/r/rust/comments/3oamul/benefits_of_rust_compared_to_go_or_haskell/).

---

<div class="post-metadata">

**Author:** ![sanxiyn](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/sanxiyn/32/8824_2.png) [@sanxiyn](https://internals.rust-lang.org/u/sanxiyn)\
**Post date:** [October 28, 2015, 8:59am UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/6 "2015-10-28T08:59:36Z")

</div>

For an opinion from the other side, one of original Go developers Ian Lance Taylor answered this question.

[https://www.quora.com/What-do-Go-programming-language-designers-think-of-Rust-programming-language](https://www.quora.com/What-do-Go-programming-language-designers-think-of-Rust-programming-language)

---

<div class="post-metadata">

**Author:** ![ak2015](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@ak2015](https://internals.rust-lang.org/u/ak2015)\
**Post date:** [October 28, 2015, 10:50pm UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/7 "2015-10-28T22:50:54Z")

</div>

Thanks for the reply. If GC is optional in Rust, then how does it do memory management? Is it same as in C with some functions like malloc() and free(). Then wouldnt we again run the risk of memory leaks or buffer overuns or so since we re managing memory? Of course, we do get full control of memory management as in C.

---

<div class="post-metadata">

**Author:** ![ak2015](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@ak2015](https://internals.rust-lang.org/u/ak2015)\
**Post date:** [October 28, 2015, 11:17pm UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/8 "2015-10-28T23:17:37Z")

</div>

Thanks, this article of reddit is quite good one.

---

<div class="post-metadata">

**Author:** ![ak2015](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@ak2015](https://internals.rust-lang.org/u/ak2015)\
**Post date:** [October 28, 2015, 11:17pm UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/9 "2015-10-28T23:17:51Z")

</div>

Thanks.

---

<div class="post-metadata">

**Author:** ![ahmedcharles](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ahmedcharles/32/4041_2.png) [@ahmedcharles](https://internals.rust-lang.org/u/ahmedcharles)\
**Post date:** [October 29, 2015, 12:06am UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/10 "2015-10-29T00:06:19Z")

</div>

I’d recommend reading the rust book, which explains ownership and memory management in Rust more completely.

[https://doc.rust-lang.org/stable/book/](https://doc.rust-lang.org/stable/book/)

---

<div class="post-metadata">

**Author:** ![steveklabnik](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/steveklabnik/32/4524_2.png) [@steveklabnik](https://internals.rust-lang.org/u/steveklabnik)\
**Post date:** [October 29, 2015, 12:37am UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/11 "2015-10-29T00:37:16Z")

</div>

> [@ak2015](#):
>
> If GC is optional in Rust,

It's not even optional, tracing GC is entirely nonexistant.

(It seems like you've found material for the rest)

---

<div class="post-metadata">

**Author:** ![lambda](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/lambda/32/292_2.png) [@lambda](https://internals.rust-lang.org/u/lambda)\
**Post date:** [October 29, 2015, 6:50am UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/12 "2015-10-29T06:50:54Z")

</div>

> [@ak2015](#):
>
> Thanks for the reply. If GC is optional in Rust, then how does it do memory management? Is it same as in C with some functions like malloc() and free(). Then wouldnt we again run the risk of memory leaks or buffer overuns or so since we re managing memory? Of course, we do get full control of memory management as in C.

Memory management in Rust is more like memory management in modern C++, but with enhancements to be fully safe. You use the RAII pattern and move semantics to acquire, release, and transfer ownership of memory allocations, and you use borrows to pass temporary references to it to code that just needs to have a reference to work with but doesn't need to own the value.

---

<div class="post-metadata">

**Author:** ![notriddle](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/notriddle/32/14082_2.png) [@notriddle](https://internals.rust-lang.org/u/notriddle)\
**Post date:** [October 29, 2015, 4:14pm UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/13 "2015-10-29T16:14:38Z")

</div>

[Rust is a lot more like chess than it is like go…](https://gist.github.com/oakes/4af1023b6c5162c6f8f0)

---

<div class="post-metadata">

**Author:** ![DenisKolodin](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/deniskolodin/32/1251_2.png) [@DenisKolodin](https://internals.rust-lang.org/u/DenisKolodin)\
**Post date:** [October 29, 2015, 9:57pm UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/14 "2015-10-29T21:57:29Z")

</div>

I have an argument that is rarely mentioned: Go like Python takes inspiration by one (Benevolent Dictator For Life). Rust is true community product. I feel the language progresses faster with more practical direction. But it’s really hard to compare it with Go.

Unsophisticated comparsion: with Rust you can write and improve Go runtime (GC, etc.), but it’s harder vice versa.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 25, 2019, 8:25am UTC](https://internals.rust-lang.org/t/go-vs-rust/2842/15 "2019-03-25T08:25:23Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
