‹ BackHN Continuity

Thread

Book review: Is parallel programming hard, and, if so, what can you do about it?

149 points · 66 comments · ahelwer

  1. criddell · · focus · HN ↗
    This review seems to equate parallelism and concurrency as the same thing and they are not.

    As I understand it, the parallelism is about task execution and concurrency is about task structure. Or, as Rob Pike said:

    "Concurrency is about dealing with lots of things at once. Parallelism is about doing lots of things at once."

    He said that in his Concurrency is not Parallelism talk.

    1. ahelwer · · focus · HN ↗
      That battle has unfortunately been lost and different sources give different definitions, often exactly swapped. This was discussed in one of the HN posts linked in the article: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=36318280">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=36318280

      In the end I don&#x27;t think it is too much of an issue. What confusion is really brought by conflating parallelism and concurrency? Sure, concurrent programs can be serialized onto a single core (that&#x27;s how deterministic simulation testing implementations like Antithesis and record &amp; replay implementations like Mozilla&#x27;s rr operate). But there isn&#x27;t some deep conceptual unlock you get by having a strict conceptual boundary between concurrency and parallelism.

      1. jerf · · focus · HN ↗
        Personally I think it&#x27;s not a good idea to think too rigidly about and try to draw a huge distinction between the two. They&#x27;re on a continuum and sometimes I&#x27;d say some things aren&#x27;t even strictly speaking &quot;between&quot; them either. Sitting down and trying to classify code into &quot;parallel&quot; and &quot;concurrent&quot; is as likely to do harm as to do any good.
        1. packetlost · · focus · HN ↗
          I firmly disagree, they are not a continuum, they are binary properties of what they describe. Code can have concurrency primitives, but parallelism primitives must necessarily come from the environment the code executes in, whether it&#x27;s multiple code streams on a multicore processor or process parallelism provided by an operating system. Programs that are parallel are necessarily also concurrent (if they must communicate between parallel executions), but the inverse is not necessarily true.

          If this distinction wasn&#x27;t important, Python&#x27;s infamous GIL would not be an issue.

          1. kccqzy · · focus · HN ↗
            I completely agree. Even in classic Python with GIL, the programmer would still have to understand concepts from concurrent programming. The asyncio package has to provide types such as Lock, Condition, Semaphore, even when it uses just one thread. The threading package on the other hand uses OS threads, and yet it provides its own version of types such as Lock, Condition, Semaphore, even if it is protected by the Python GIL. The GIL is preventing meaningful parallelism in Python, but it remains the programmer’s responsibility to use concurrency tools correctly.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.