Go vs C++: performance comparison to business card ray tracer

dk 158 Oct 05, 2013 at 06:44 raytracing

Discuss link: Go vs C++: performance comparison to business card ray tracer (kidoman.com)

This is a 3-part series article about Go vs C++ in implementing a raytracer (part2 & part3). To quote the summary:

After optimizations, the Go ray tracer was 8.4 % faster than a functionally equivalent C++ (but unoptimized*) version when rendering a 4.2 MegaPixel image using a single thread. With multi-threading enabled, the performance gap widened to 76.2 % on a 8 Core machine. Not only was it really simple to utilize the complete CPU in Go, it was easy to immediately feel productive in the language due to its simple and thoughtful design.

The performance comparison isn’t really fair though, given the C++ implementation is unoptimized. With an optimized C++ version in the third part of the article, C++ won by 2x. However, the author makes the case that Go makes multicore programming simpler. I’m not really familiar with Go to make that judgement, but with C++11 and the plethora of libraries available, you can have similar multicore programming constructs in C++. It’s a cool exercise nevertheless.

3 Replies

Please log in or register to post a reply.

fireside 141 Oct 05, 2013 at 07:44

Pretty cool. Go definitely looks like something to keep an eye on.

TheNut 179 Oct 05, 2013 at 15:30

I agree that his benchmarks are off. It’s also a bit misleading to compare performance between two languages. It’s all about the compiler and it’s ability to generate fast machine code, and of course how efficiently designed is your code. A more accurate benchmark between the two can be found here

I only read bits and pieces about Go, but I consider it more of a hobby language like Ruby and Perl. Use it if you want, but I wouldn’t try to convince the world that it’s a better alternative. The article would have been better served if the author focused more on providing a glimpse into Go and how he used it to build his ray tracer.

fireside 141 Oct 05, 2013 at 16:10

I don’t think it’s like Ruby or Perl because it was built a little more for speed and parallel programming. It sounds like there’s still a ways to go with it to get the speed up to max. It’s really a very new language. I think 2003 or was it 9, so the results are fairly impressive. I would consider it a hobby language in that it’s not stable or used by enough people yet. It’s also capable of using c libraries from what I gathered looking around a little. Sounds pretty promising to me. Mostly something to watch for now, though. If someone writes an engine with it, then it would be interesting.