3

I’m a student currently working on my dissertation about Raku, for which I have decided to evaluate whether Raku (Perl 6) is a good language when dealing with high concurrency.

I haven't been able to find any papers about Raku's concurrency except for the official website. Also, I have no idea about how to evaluate Raku's concurrency (e.g., what program should I use, which language should be compared with Raku, etc.).

What concurrency mechanisms are provided by Raku? Where are these documented? How can their functionality and performance be evaluated?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Vivelakira
  • 119
  • 3
  • 4
    This question is being discussed [on Meta](https://meta.stackoverflow.com/questions/404582/failed-review-audit-by-voting-to-close). – Ian Campbell Jan 20 '21 at 15:02

3 Answers3

17

Raku provides a number of different concurrency mechanisms (and furthermore provides for a number of parallel programming approaches too, but I'll assume the question is really just about concurrency). The majority of what is in Raku can be found in other languages; for example:

  • The gather/take mechanism for lazily producing values. This is seen in various languages as generator functions; in Raku, however, there is not a single stack frame limit, so they are coroutine powerful. (This isn't of in any context involving asynchronous programming, but it's still meets the definition of concurrency).
  • The Promise mechanism for conveying a single result of an asynchronous operation is a lot like Promises in JavaScript or Task in .Net (the semantics are a bit closer to the latter).
  • A Supply is a stream of asynchronous values. It has quite a bit in common with the reactive extensions (Rx), however has picked a naming and API that fits in with the overall Raku language design (for example, method names match their synchronous duals on sequences).
  • A Channel is a concurrent queue, which has a mechanism to convey completion and error, which means that you can easily transition betwee the Supply and Channel paradigms. The key difference is that a Channel has storage - you can put values into it, and immediately move on to do something else - while if you emit a value into a Supply you pay the processing costs (giving a backpressure mechanism). Various architectures can be built using Channels, such as a staged event-driven architecture.

The most distinctive concept in Raku, which does not exist directly in other languages, is the react/supply/whenever construct. Writing processors of multiple asynchronous streams is often challenging (subscription management, concurrency control); the construct provides a structured programming approach to it. Beyond that, it's mostly a question of language integration being a bit stronger in Raku, rather than treating these things just as libraries.

As others have noted, there's not much in the way of formal papers yet. However, these slides may be of interest (disclaimer: they're mine; I contributed to the Raku concurrency design, and invented react/supply/whenever).

Jonathan Worthington
  • 29,104
  • 2
  • 97
  • 136
9

Papers about Raku's concurrency: If you want description of how concurrency works, there are no academic papers I know of. You can look up in some Advent Calendar publications, for instance this one about concurrency in HTTP servers. Most books about Raku, like my own Raku Recipes (published by Apress), contain a chapter about Concurrency, so that's something you can check out too. Finally, this paper I co-authored uses Raku's concurrency for evolutionary computation, to good results.

How to evaluate Raku’s concurrency:* Raku uses communicating sequential processes, and it uses Channels as first class objects. In that sense, it's similar to Go. On the other hand, it's able to auto-thread data flows via hyper/race in the same way that Julia does via macros. So those could be two targets for comparison.

Perhaps the perl6-users mailing list would be a better place to ask questions like this.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
jjmerelo
  • 22,578
  • 8
  • 40
  • 86
5

The CSP built in to raku is a well established concurrency model conceived by Tony (Anthony) Hoare. You may also want to look for work by Bill (William) Roscoe that continued Tony’s line of research. Note that this will be general CSP research. I doubt that there is anything referenceable yet done specifically on Raku.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
librasteve
  • 6,832
  • 8
  • 30