Tracks
/
Wren
Wren
/
Exercises
/
Parallel Letter Frequency
Parallel Letter Frequency

Parallel Letter Frequency

Medium

Instructions

Count the frequency of letters in texts using parallel computation.

Parallelism is about doing things in parallel that can also be done sequentially. A common example is counting the frequency of letters. Employ parallelism to calculate the total frequency of each letter in a list of texts.

Concurency vs. Parallelism

Wren provides concurrency via a construct called fibers. From the Wren manual:

Fibers are a bit like threads except they are cooperatively scheduled. That means Wren doesn’t pause one fiber and switch to another until you tell it to.

Wren's execution is single-threaded so we don't actually get parallelism.

Here's a quick definition for each that illustrates the diferences between the two:

  • Concurrency is when two or more tasks can start, run and complete in overlapping time periods, being executed by the same processing unit.
  • Parallelism is when two or more tasks can start and run at the same time, being executed independently of eachother by separate processing units.

Read more about concurrency in Wren.

Edit via GitHub The link opens in a new window or tab
Wren Exercism

Ready to start Parallel Letter Frequency?

Sign up to Exercism to learn and master Wren with 99 exercises, and real human mentoring, all for free.

Deep Dive into Parallel Letter Frequency!

We explore the differences between concurrency and parallelism, looking at different approaches taken by languages such as JavaScript, Go, Elixir and Rust.