Skip to content

Commit adcda70

Browse files
authored
Note on parallelism (#2735)
* Parallel Letter Frequency: Requires Node.js / CLI * Unify JavaScript casing * Unify exercism notice usage * More speaking link text
1 parent 519ed18 commit adcda70

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

exercises/practice/parallel-letter-frequency/.docs/instructions.append.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# Instructions append
22

3-
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.
3+
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.
44
In fact, the only way to achieve "real" parallel code execution is through `Worker threads` (also reffered to as `Web Workers`).
55

66
Almost always, code that appears to execute in parallel,
77
such as `async functions` or `Promises`, will actually execute concurrently instead.
8-
This is often better, since modern Javascript is optimized for such use,
8+
This is often better, since modern JavaScript is optimized for such use,
99
and you will often see code that "emulates" (or "cheats") parallel execution by the use of `Promise.all()` and other concurrent execution methods.
1010

11-
```exercism/caution
11+
<!-- prettier-ignore -->
12+
~~~@exercism/caution
1213
To pass the tests for this exercise, your solution needs to execute _concurrently_ (or in parallel),
1314
meaning that synchronous solutions (e.g. a simple `for` loop) will not pass.
14-
```
15+
~~~
1516

1617
## Concurency vs. Parallelism
1718

@@ -24,26 +25,27 @@ For the sake of completeness, here's a definition for synchronous execution:
2425

2526
- Synchronous execution is when a task has to wait for another running task to complete, before it can run.
2627

27-
## Parallelism in Javascript
28+
## Parallelism in JavaScript
2829

29-
Even though Javascript by default is single-threaded, there is a way to execute code in parallel fashion.
30+
Even though JavaScript by default is single-threaded, there is a way to execute code in parallel fashion.
3031

31-
If your running javascript in the browser (e.g. in a web app),
32+
If you are running JavaScript in the browser (e.g. in a web app),
3233
then the way to achieve parallelism is through the [Web Worker API][mdn-demo].
3334
As described by MDN:
3435

3536
> Web Workers makes it possible to run a script operation in a background thread separate from the main execution thread of an application.
3637
37-
On the other hand, if your javascript is running in Node.js, which is Exercism's target runtime,
38+
On the other hand, if your JavaScript is running in Node.js, which is Exercism's target runtime,
3839
this same concept is known as [Worker threads][node].
3940

40-
```exercism/caution
41+
<!-- prettier-ignore -->
42+
~~~@exercism/caution
4143
Be aware that the implementation of the worker API differs largely between browsers and other JavaScript environments.
4244
4345
Make sure to read the documentation for your specific runtime!
44-
```
46+
~~~
4547

46-
Here's a simple demo of the `Web Worker API` (taken from [here][medium-demo])
48+
Here's a simple demo of the `Web Worker API` (taken from [Medium][medium-demo])
4749

4850
```js
4951
// main.js
@@ -100,6 +102,13 @@ if (isMainThread) {
100102
}
101103
```
102104

105+
<!-- prettier-ignore -->
106+
~~~@exercism/caution
107+
Currently it is not possible to implement parallelism using the online editor.
108+
109+
Please implement `Worker threads` using Node.js locally and submit your solution via CLI!
110+
~~~
111+
103112
As a stretch goal, consider if your implementation can be adapted to make use of `Worker threads`.
104113

105114
---

0 commit comments

Comments
 (0)