Skip to content

Commit

Permalink
starting on parallel doc
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenjw committed Sep 9, 2023
1 parent 528afd4 commit d1ddf96
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
21 changes: 20 additions & 1 deletion Scala/docs/Parallel.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Scala parallel crash course
# Scala parallel programming crash course

## Parallel collections

This simplest (but by no means the only) way to get started with parallel programming in Scala is using Scala [parallel collections](https://docs.scala-lang.org/overviews/parallel-collections/overview.html).

```scala
val rng = scala.util.Random(42)
val v = Vector.fill(10)(rng.nextGaussian)
v

```



## Futures




## Effects

Futures are a powerful and flexible way to construct parallel and concurrent applications. However, they aren't a perfect fit to a pure functional approach to programming. The fact that futures "fire" as soon as they are created means that they have a *side-effect*, and that is potentially problematic. People have developed more principled, functional effects systems for Scala, such as the [Cats effect](https://typelevel.org/cats-effect/) IO monad, and these provide better mechanisms for parallel and concurrent programming in Scala. They are, however, (well) beyond the scope of this course.

21 changes: 20 additions & 1 deletion Scala/md/Parallel.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Scala parallel crash course
# Scala parallel programming crash course

## Parallel collections

This simplest (but by no means the only) way to get started with parallel programming in Scala is using Scala [parallel collections](https://docs.scala-lang.org/overviews/parallel-collections/overview.html).

```scala
val rng = scala.util.Random(42)
val v = Vector.fill(10)(rng.nextGaussian)
v

```



## Futures




## Effects

Futures are a powerful and flexible way to construct parallel and concurrent applications. However, they aren't a perfect fit to a pure functional approach to programming. The fact that futures "fire" as soon as they are created means that they have a *side-effect*, and that is potentially problematic. People have developed more principled, functional effects systems for Scala, such as the [Cats effect](https://typelevel.org/cats-effect/) IO monad, and these provide better mechanisms for parallel and concurrent programming in Scala. They are, however, (well) beyond the scope of this course.

2 changes: 1 addition & 1 deletion Scala/md/ScalaCC.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def linFun(m: Double, c: Double)(x: Double): Double =
m*x + c

val f = linFun(2, 3)
// f: Function1[Double, Double] = repl.MdocSession$MdocApp$$Lambda$8059/0x0000000802036010@781857e7
// f: Function1[Double, Double] = repl.MdocSession$MdocApp$$Lambda$8067/0x00000008020f5e08@4afe4c5d

f(0)
// res22: Double = 3.0
Expand Down

0 comments on commit d1ddf96

Please sign in to comment.