Hacker News new | ask | show | jobs
by 37ef_ced3 1766 days ago
Go should be understood as a replacement for C and C++.

If you're writing a compiler, or some other project where extreme high performance is not necessary (e.g., if you're willing to be, say, a factor of 2 slower than C) then Go is a good choice.

Go's performance is excellent, and should be sufficient for all but the most demanding applications. It's not a crummy scripting language like Python/JS.

2 comments

> Go should be understood as a replacement for C and C++.

I think Go is a good replacement for the things people used C and C++ for twenty years ago, but less of a replacement for the things people use C and C++ for today.

Back then, C/C++ was your default "write big server program that needs to go relatively fast" language, and Go is targeting that. But in the meantime, Java got fast enough and hardware got cheap enough that Python, Ruby, and JavaScript have also eaten into that domain.

Today, I see C and C++ used primarily for embedded work and games. I don't see Go as being a great fit for either of those.

Go is a replacement for a certain subset of C/C++ projects that are I/O heavy, e.g. web servers. However the GC precludes it from many uses of C/C++, e.g. you couldn't write an AAA game in it, or a kernel, or a toaster.
Yeah but how often do we meet toaster devs?
The toaster industry has a big problem with burnout.
GC is quite problematic for web servers too. Lots of people "solve" that by giving AWS more money.
Web server workers, by definition, don't run for extended periods. Making them the perfect candidate for GC languages.

  1) Get request
  2) Serve request
  3) Get GC'd
No memory issues.
Serving web requests with ephemeral workers introduces some new problems though. Generally efficiency in this space comes from pooling, reusing connections, multiplexing etc ...

Ie. amortize expensive work over many requests.

Why is GC problematic for web servers?
Because GC will pause threads while requests are being served, this leads to latency spikes at the higher percentiles.

It introduces a whole distinct type of complexity into operating the server.

The latency of a request to your server is not just caused by the code that is ran to serve that request (which is how people intuitively would think about it), it can be caused by GC pauses that are happening because of the memory pressure caused by previous requests.