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

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
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
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
How similar is GO to C?
They are particularly similar in style. Ken Thompson and Rob Pike worked at Bell Labs after all, with Ken having been one of the first users of C in general. Rob wrote his notes on programming in C in the late 80s, which IMHO is still great advice for writing good C code. Much of the most beautiful C I've seen is from the source code of Plan 9, an operating system they developed at Bell Labs. So when they created Go, they came from a C background, in the sense that they hadn't only used C for decades, but also helped shape it from the very beginning. One of the best aspects of C is how orthogonal it feels. You write your structs that are plain data. You write your functions that are plain code. Your functions do what you see written. No more, no less. Go feels very similar to that. It doesn't try to retain any kind of compatibility with C, but rather tries to distill its spirit even further, with even fewer keywords (none of which are adjectives, which means you don't get tons of weird interactions of modifiers like e.g. in Java). It's definitely higher level than C. Your indices are bounds checked, memory is automatically allocated and freed as you use it, etc. So no dangling pointers and segfaults to worry about, but it still gives you the ability to have a pointer point at some value inside another data structure. There's no pointer arithmetic but there are slices which can often be used in similar ways. More on reddit.com
🌐 r/golang
18
36
April 13, 2023
🌐
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.)
🌐
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
C in theory can do as well - in ... 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....
🌐
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 programs can be just as fast as C programs, and in some cases even faster. Goland speed and Golang performance is great, as its built-in support for concurrency and memory safety also make it easier to write high-performance code.
🌐
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.
Find elsewhere
🌐
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...
🌐
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…
🌐
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...
🌐
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
🌐
Boot.dev
blog.boot.dev › golang › go-vs-c-plus-plus-golang
Golang vs C++: Which Is Best for Your Next Project | Boot.dev
October 1, 2022 - While Go and C++ both compile directly to binary code, it’s easy to make the case that Go is “higher-level” than C++ because it contains a runtime in each executable program that manages memory and performs basic administrative tasks “under the hood”. ... Golang is a higher-level language.
🌐
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++.
🌐
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
🌐
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).
🌐
Stack Overflow
stackoverflow.blog › 2022 › 04 › 04 › comparing-go-vs-c-in-embedded-applications
Comparing Go vs. C in embedded applications - Stack Overflow
April 4, 2022 - While this can be quite subjective, Go can be a very productive language for embedded development. This is especially true when it comes to network programming, which is at some point a part of every connected device or application. Go was created by Google to meet the needs of Google developers, and it was mainly developed to try to fix the explosion of complexity within its ecosystem.
🌐
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.
🌐
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.