C++ vs Go for Backend Services: Memory, Concurrency and Trade-offs
ByteDanceSoftware Engineer · Technical ScreenLast updated
From a TikTok backend intern interview: compare C++ and Go across memory management, concurrency, error handling, language features and tooling, and explain when each language is the better choice for a service. It tests practical understanding of runtime trade-offs rather than syntax trivia.
Compare C++ and Go. Explain the main differences between the two languages and when you would choose each one, for example for the backend services this team builds.
Clarifying Questions
- Should the comparison focus on writing backend services, or on systems programming in general?
- Which C++ standard should be assumed, since modern C++ (smart pointers, move semantics, coroutines) changes several answers?
Hints
Hint 1
Organize by runtime model: Compare how each language manages memory, runs concurrent work, reports errors and builds and ships its binaries, then ask what each difference costs or buys a backend service.
Follow-up questions
- How does the Go scheduler run goroutines on OS threads, and what happens when a goroutine makes a blocking system call?
- What do `std::unique_ptr` and `std::shared_ptr` each cost, and when does `shared_ptr` cause problems?
- How does Go's escape analysis decide whether a value lives on the stack or the heap, and why does that matter for garbage collection?
- Go has no exceptions. How do you propagate and wrap errors, and when is `panic` appropriate?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.