From cae2bfff32352f552a954c3f39c24886f545e43c Mon Sep 17 00:00:00 2001 From: Michael Kramer Date: Mon, 28 Jul 2025 15:32:23 +0200 Subject: [PATCH 1/4] Parallel Letter Frequency: Requires Node.js / CLI --- .../parallel-letter-frequency/.docs/instructions.append.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md b/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md index 71bf279275..6e685420ce 100644 --- a/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md +++ b/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md @@ -100,6 +100,13 @@ if (isMainThread) { } ``` + +~~~@exercism/caution +Currently it is not possible to implement parallelism using the online editor. + +Please implement `Worker threads` using Node.js locally and submit your solution via CLI! +~~~ + As a stretch goal, consider if your implementation can be adapted to make use of `Worker threads`. --- From 5a754940fd9a0da613a38ff0318bdb6c26de4a19 Mon Sep 17 00:00:00 2001 From: Michael Kramer Date: Mon, 28 Jul 2025 15:33:08 +0200 Subject: [PATCH 2/4] Unify JavaScript casing --- .../.docs/instructions.append.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md b/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md index 6e685420ce..633507f7da 100644 --- a/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md +++ b/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md @@ -1,11 +1,11 @@ # Instructions append -Javascript is single-threaded by nature, so it lacks many of the language features that other languages have in order to handle parallel code execution. +JavaScript is single-threaded by nature, so it lacks many of the language features that other languages have in order to handle parallel code execution. In fact, the only way to achieve "real" parallel code execution is through `Worker threads` (also reffered to as `Web Workers`). Almost always, code that appears to execute in parallel, such as `async functions` or `Promises`, will actually execute concurrently instead. -This is often better, since modern Javascript is optimized for such use, +This is often better, since modern JavaScript is optimized for such use, and you will often see code that "emulates" (or "cheats") parallel execution by the use of `Promise.all()` and other concurrent execution methods. ```exercism/caution @@ -24,17 +24,17 @@ For the sake of completeness, here's a definition for synchronous execution: - Synchronous execution is when a task has to wait for another running task to complete, before it can run. -## Parallelism in Javascript +## Parallelism in JavaScript -Even though Javascript by default is single-threaded, there is a way to execute code in parallel fashion. +Even though JavaScript by default is single-threaded, there is a way to execute code in parallel fashion. -If your running javascript in the browser (e.g. in a web app), +If you are running JavaScript in the browser (e.g. in a web app), then the way to achieve parallelism is through the [Web Worker API][mdn-demo]. As described by MDN: > Web Workers makes it possible to run a script operation in a background thread separate from the main execution thread of an application. -On the other hand, if your javascript is running in Node.js, which is Exercism's target runtime, +On the other hand, if your JavaScript is running in Node.js, which is Exercism's target runtime, this same concept is known as [Worker threads][node]. ```exercism/caution From 31a1df5fd782f60f03948634e61c8f6fd1bd808e Mon Sep 17 00:00:00 2001 From: Michael Kramer Date: Mon, 28 Jul 2025 15:33:37 +0200 Subject: [PATCH 3/4] Unify exercism notice usage --- .../.docs/instructions.append.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md b/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md index 633507f7da..f6a3eb079f 100644 --- a/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md +++ b/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md @@ -8,10 +8,11 @@ such as `async functions` or `Promises`, will actually execute concurrently inst This is often better, since modern JavaScript is optimized for such use, and you will often see code that "emulates" (or "cheats") parallel execution by the use of `Promise.all()` and other concurrent execution methods. -```exercism/caution + +~~~@exercism/caution To pass the tests for this exercise, your solution needs to execute _concurrently_ (or in parallel), meaning that synchronous solutions (e.g. a simple `for` loop) will not pass. -``` +~~~ ## Concurency vs. Parallelism @@ -37,11 +38,12 @@ As described by MDN: On the other hand, if your JavaScript is running in Node.js, which is Exercism's target runtime, this same concept is known as [Worker threads][node]. -```exercism/caution + +~~~@exercism/caution Be aware that the implementation of the worker API differs largely between browsers and other JavaScript environments. Make sure to read the documentation for your specific runtime! -``` +~~~ Here's a simple demo of the `Web Worker API` (taken from [here][medium-demo]) From 6aaf0dc54cf11c8e35fae21c0d6592be204dd980 Mon Sep 17 00:00:00 2001 From: Michael Kramer Date: Mon, 28 Jul 2025 15:34:03 +0200 Subject: [PATCH 4/4] More speaking link text --- .../parallel-letter-frequency/.docs/instructions.append.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md b/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md index f6a3eb079f..f17f872d0d 100644 --- a/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md +++ b/exercises/practice/parallel-letter-frequency/.docs/instructions.append.md @@ -45,7 +45,7 @@ Be aware that the implementation of the worker API differs largely between brows Make sure to read the documentation for your specific runtime! ~~~ -Here's a simple demo of the `Web Worker API` (taken from [here][medium-demo]) +Here's a simple demo of the `Web Worker API` (taken from [Medium][medium-demo]) ```js // main.js