‹ BackHN Continuity

Thread

Go Concurrency Distilled

402 points · 187 comments · chmaynard

  1. SamInTheShell · · focus · HN ↗
    The concurrency and threading in Go just feels like magic compared to every other language. I'm a goroutine addict and I refuse to be rehabilitated.

    Just from observations over the years, I don't think there's any other language quite like this, in terms of how things can end up happening in any thread.

    1. za3faran · · focus · HN ↗
      Java is doing it better (virtual threads + structured concurrency + immutable records and immutable value types).

      Not to mention golang is not memory safe: <a href="https:&#x2F;&#x2F;www.ralfj.de&#x2F;blog&#x2F;2025&#x2F;07&#x2F;24&#x2F;memory-safety.html" rel="nofollow">https:&#x2F;&#x2F;www.ralfj.de&#x2F;blog&#x2F;2025&#x2F;07&#x2F;24&#x2F;memory-safety.html

      1. SamInTheShell · · focus · HN ↗
        I don&#x27;t think you understand the threading concurrency topic. Also memory safety is so far off base here, where&#x27;s that coming from? Java does some stuff okay, but do you really want to defend the horrid JVM problems? Also why can&#x27;t I have my memory back when it&#x27;s not in use in tightly packed systems?

        It&#x27;s not great for everything and neither is Go. You can find a bit more context on that in some of the other threads.

        1. gf000 · · focus · HN ↗
          &gt; defend the horrid JVM problems

          Such as? It&#x27;s one of the most widely used platform for backend services, basically almost all top 500 company has some business critical infrastructure running Java. It surely can&#x27;t have &quot;too horrid&quot; problems..

          1. SamInTheShell · · focus · HN ↗
            I gave an example. Go allocate 8 gigs. Then get it garbage collected. Why is JVM still allocating 8 gigs?
            1. za3faran · · focus · HN ↗
              We have Java services running on 512MB k8s nodes.

              Furthermore, collection time (for moving collectors) is a function of the liveset, not the # of dead objects.

              1. SamInTheShell · · focus · HN ↗
                Still doesn&#x27;t answer the question. In Java, allocate 8 gigs. Free 7 gigs. Why still 8 gigs? I didn&#x27;t ask anything about if I could run a 1 gig process here.
                1. za3faran · · focus · HN ↗
                  It depends on the GC settings. With the other JEPS I listed, things should become more aggressive. But today you can have:

                      &gt; java -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 test.java
                      used=7640 MB, committed=7668 MB, max=8192 MB
                      used=4 MB, committed=20 MB, max=8192 MB
                      used=3 MB, committed=8 MB, max=8192 MB
                      used=3 MB, committed=8 MB, max=8192 MB
                  
                  The RSS drops from ~8GB to 8 MB.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.