The Go compiler has a good balance between compilation speed and optimization. Answer from Thaxll on reddit.com
🌐
Reddit
reddit.com › r/golang › why is golang not as performant as c or c++?
r/golang on Reddit: Why is Golang not as performant as C or C++?
January 12, 2019 -

Hi all,

First of all, forgive me to ask this. I am a noob to Golang and find it very promising to learn. I read that Golang is not as performant as C or C++ code. What's the reason behind this? AFAIK Golang is very close to C or inherits many features. If this is the case, why is Golang gaining popularity? How about the future of Golang developers? What's the primary domain of use - cloud?

Top answer
1 of 14
248

Some people like to blame all of the slowness of languages like Go, C#, and Java on garbage collection, but that isn't a very complete story. People will correctly tell you that normally garbage collection takes up a very very small % of total runtime, and that is true, so what else is going on? There are some indirect and related things as well.

  • Languages that have garbage collection are attempting to be memory safe languages, so:

    • They will also tend to have array bounds checks when the compiler can't prove they can be elided

    • They will tend not to allow as many clever casts

    • They will tend not to allow pointer arithmetic

    • Providing ways to leverage SIMD instructions by hand is hard (Go gives access only through Go assembler at the moment)

    • They will tend not to have a way for the compiler to do floating point optimizations that can change results like --ffast-math in C compilers

  • Garbage Collection has some indirect effects aside from how much time is spent doing GC

    • Every time the GC runs it pollutes the CPU caches, slowing down code that runs later

    • GC will normally imply a degree of overhead when doing FFI (interop with other languages). Go has even more overhead due to how it manages it's stack, which facilitates goroutine features. Lots of things require FFI still (3d rendering, for example) so those things will always be slower.

    • The control you get over memory layout of your data is usually limited to some degree. For instance in Go you can't explicitly control whether data goes on the stack, or heap, or *where* to goes on the heap. On the bright side in Go you can at least work with any type you create as a value or a reference, so you can at least control things like making sure your array is an array of values in contiguous memory vs an array of references, which you can't in Java. Accessing RAM is very slow, controlling memory layout on modern computers can be a big deal, assuring that you hit the L1 and L2 cache as much as possible.

There are also just some cultural things, people working on the C and C++ ecosystems are doing so because performance is priority one. People working on ecosystems of memory safe languages obviously have a bit of priority for safety, correctness, or productivity or they wouldn't want the GC!

None of these things in isolation is normally a very big deal but they can add up.

2 of 14
44

There are tons of differences in the implementations of C and Go that slightly slow down Go in favour of safety. A few things:

  • goroutine scheduling

  • growing stacks

  • Runtime checks for memory access (you panic on nil not segfault)

  • runtime reflection

  • Bounds checking on arrays/slices

  • No naive casting (safe type assertion)

  • Different calling conventions

    • this allows panics at any pint

    • Go relies more on the stack (no fastcall)

  • Defer

  • Much fewer optimizations in favour of fast compile times

  • latency optimized GC, this limits throughput

All of this and much more lead to the fact that cgo has quite some overhead.

C is still the most dominant language and this will be remain true longer than we all live. Go improves C in lots of aspects that address issues faced today.

  1. Go is memory safe making it way less dangerous to program critical systems

  2. Great multicore capabilities in times after Moore's law

  3. Go scales great

🌐
Medium
medium.com › @marek.michalik › c-vs-rust-vs-go-performance-analysis-945ab749056c
C vs Rust vs Go: performance analysis | by Marek Michalik | Medium
July 18, 2019 - C and Rust are using single, raw block of memory. So when you need to take 15th pixel from image you just access it by image[15]. But Go have special struct for dealing with images https://golang.org/pkg/image/#Image When you need a pixel form image in Go you use .At(x, y int) method. For some reason At method doesn’t perform as efficient as accessing memory directly.
Discussions

What is the theoretical / practical limit of golang vs c / c++? Statement of Rob on memory communication needs appending - Technical Discussion - Go Forum
i’m always pushing for performance of golang and found a lot of areas whereby go is slower than c equivalent at 2x and 1.2x etc but wondering what’s the theoretical / practical limit of golang. especially in multi core (448 cpu core) environment etc. i’ve been using using go for the past ... More on forum.golangbridge.org
🌐 forum.golangbridge.org
0
April 13, 2024
Rust vs. C vs. Go runtime speed comparison
I have written the same simple numerical program in Rust, C, Go, and was hoping that Rust runtime would be about as fast as C. It turns out that it is 10x slower than the best C compiled program, and 7x slower than the go version. compiler opt_level runtime ratio vs. best gcc -O3 1.54 1.0 clang ... More on users.rust-lang.org
🌐 users.rust-lang.org
20
1
December 18, 2023
Development speed comparison for C/C++ vs Golang - Technical Discussion - Go Forum
Hello, I was wondering if there are any studies that compare golang with C/C++ regarding initial development speed. Has anyone studies this subject? Has anyone implemented a component with both languages and compared the development speeds? Thanks, Umut More on forum.golangbridge.org
🌐 forum.golangbridge.org
0
September 17, 2019
Is Golang really a competitor to C++ ?
It was meant to displace C++ for server code at Google. Not for all the other stuff C++ does. And Pike said later they were somewhat successful at that but not as much as they wanted. More on reddit.com
🌐 r/golang
187
133
March 21, 2024
🌐
Quora
quora.com › How-does-the-speed-of-Golang-compare-to-that-of-C-C-Python-and-Rust
How does the speed of Golang compare to that of C, C++, Python, and Rust? - Quora
Answer: In general, you will find Golang is roughly the same as C, C++ or Rust, slower than well written and optimised C, C++ or Rust, and much faster than Python. But that is a generalisation.
🌐
Programming Language Benchmarks
programming-language-benchmarks.vercel.app › go-vs-c
Go VS C benchmarks, Which programming language or compiler is faster
* (You may find time < time(user) + time(sys) for some non-parallelized programs, the overhead is from GC or JIT compiler, which are allowed to take advantage of multi-cores as that's more close to real-world scenarios.)
🌐
Avatao
avatao.com › home › go vs c: why consider go instead of c?
Go vs C: Why Consider Go Instead of C? -
July 2, 2025 - Go is a powerful, efficient, modern, ... simplicity, and cross-compilation make it a great choice for developers. Golang performance is comparable to C and it can be a great choice for many types of projects....
🌐
Google Groups
groups.google.com › g › golang-nuts › c › n12khle-mlY
Go vs C speed - What am I doing wrong?
> Contributors can recreate the same benchmarking routines in C, golang, JS This is how "benchmark game" **entertaining** sites are architectured. Their "comparisons" are moot for the industry. Look at the history of java samples and benchmark earlier vs current at same task. "Look at the history of java samples and benchmark earlier vs current at same task" and conclude what? > Robert Engels wrote:The point is that when you leverage a runtime, you often get performance improvements as the runtime improves with no work on your end.
🌐
Go Forum
forum.golangbridge.org › technical discussion
What is the theoretical / practical limit of golang vs c / c++? Statement of Rob on memory communication needs appending - Technical Discussion - Go Forum
April 13, 2024 - i’m always pushing for performance of golang and found a lot of areas whereby go is slower than c equivalent at 2x and 1.2x etc but wondering what’s the theoretical / practical limit of golang. especially in multi core (448 cpu core) environment etc. i’ve been using using go for the past 6 years daily and with extreme efficiency consideration only going for zero alloc stuff but i’m wondering how far can i push golang before i need to always look at c / c++ / rust. in an “unrelated issue”, this...
Find elsewhere
🌐
Go Forum
forum.golangbridge.org › technical discussion
Development speed comparison for C/C++ vs Golang - Technical Discussion - Go Forum
September 17, 2019 - Hello, I was wondering if there are any studies that compare golang with C/C++ regarding initial development speed. Has anyone studies this subject? Has anyone implemented a component with both languages and compared th…
🌐
Shawn's Blog
basicallyshawn.com › 2024 › 04 › 29 › go-vs-c-first-glance
Go vs. C++, First Glance | Shawn's Blog
April 29, 2024 - Go’s garbage collection, on the other hand, runs concurrently with the application and employs a mark-and-sweep algorithm. This algorithm can be further explored in the Go garbage collection guide (https://tip.golang.org/doc/gc-guide).
🌐
Hacker News
news.ycombinator.com › item
Is Golang significantly slower than c++ ? I thought Google had invented Golang t... | Hacker News
July 2, 2019 - I had thought most of the systems code inside Google would be golang by now. is that not the case ? the code doesnt look too big - I dont think porting is the big issue · Rewriting decades of core business logic would be a tremendous effort and amount of risk
🌐
Career Karma
careerkarma.com › blog › tech guides › go vs c++ compared and contrasted
Go vs C++: A Complete Comparison | Career Karma
July 20, 2022 - However, in order to achieve this higher performance you have to take advantage of C++’s lower level language features and optimize it at the microlevel. ... Because C# is a higher-level language than C++, its coding time is less. While C++ is a faster program, coding with C++ tends to take longer. ... Although the programming language is frequently referred to as “Golang...
🌐
Google Groups
groups.google.com › g › golang-nuts › c › WBnqwLjzTmE
Achieving C/C++/Rust comparable performance with Golang
December 14, 2022 - Go is a high performant garbage collected language, (considered) memory safe programming language, and as such its performance may not be comparable with other languages such as C/C++/Rust under certain application scenarios.
🌐
Sololearn
sololearn.com › en › Discuss › 2649370 › is-golang-actually-as-fast-as-cc
Is Golang actually as fast as C/C++?
Sololearn is the world's largest community of people learning to code. With over 25 programming courses, choose from thousands of topics to learn how to code, brush up your programming knowledge, upskill your technical ability, or stay informed about the latest trends.
🌐
Blackdown
blackdown.org › home › golang vs. c++ – a complete comparison
Golang vs. C++ - A Complete Comparison - Blackdown
October 2, 2025 - Go has many built-in features that make writing code simple. However, its trash collector slows Go’s performance. If we compare C++ vs Golang performance, Go is not slower than C++.
🌐
Orient Software
orientsoftware.com › blog › golang-performance
Golang Performance: Go Programming Language vs. Other Languages
July 4, 2023 - Usage: Google designs Go language to meet the needs of parallel computing environments, especially web applications, data science, cloud infrastructure, machine learning applications, etc., due to its innovative library, solid security, and steady performance. The Go documentation describes Go itself as “an open-source programming language that makes it easy to build simple, reliable, and efficient software.” In fact, the Go language offers large development teams even more advantages. Similar to other programming languages, speed is considered the most important factor for any software development solution. Golang speed depends on a lot of reasons.
🌐
Slant
slant.co › versus › 113 › 126 › ~c_vs_go
Slant - C vs Go detailed comparison as of 2026
When comparing C vs Go, the Slant community recommends C for most people. In the question "What are the best compiled programming languages?" C is ranked 1st while Go is ranked 3rd
🌐
CodiLime
codilime.com › blog › software development › backend › go vs. c++ — main differences: speed, benefits, exception handling
Go vs. C++ — Main Differences: Speed, Benefits, Exception Handling
September 23, 2021 - But the main part of the comparison will focus on the speed and readability level of these languages, whether one of them is more secure, and how test code coverage and execution handling look in Go and C++. Also, I’ll mention the benefits of each, and why they are worth your attention. Go, often referred to as “Golang”, is an open source programming language, known for its simplicity. A really strong feature of Go is its built-in support for parallel processing. Go mixes the features of statically-typed languages, such as high performance and type safety, with the features of dynamically-typed and interpreted languages, such as conciseness, expressiveness, readability, and the ability to run code quickly.