Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Concurrency vs. Parallelism - Codelovers 2013

Concurrency vs. Parallelism - Codelovers 2013

Version of this talk for the generalist audience at the Codelovers meetup.

Federico Ravasio

March 25, 2013
Tweet

More Decks by Federico Ravasio

Other Decks in Programming

Transcript

  1. Idea #1 (cont.) AKA: putting the burden of synchronization on

    the programmer. Also, shared memory :(
  2. The common feeling: Managing threads is hard and gets in

    the way of describing the higher-level problem at hand
  3. I've met a number of people who say “Well, I

    know you don't believe it, but I can write successful threaded programs.” I used to think that, too. But now I think it's just a learning phase, and you aren't reliable until you say “It's impossible to get it right”. http://www.haskell.org/pipermail/haskell-cafe/2008-September/047234.html
  4. If you have to do it, do it this way:

    - Build small well-described pieces - Reduce causality - Minimize shared state - Use the right synch tool
  5. Idea #2 Design a language with concurrent primitives and let

    the compiler/VM take care of the hard stuff
  6. The Actor Model Kevin Spacey Msg #1 Msg #2 ...

    Kate Mara Msg #1 Msg #2 ... Asynchronous messaging
  7. Idea #3 We write immutable, side-effect free code and let

    the compiler/VM take care of the rest
  8. Idea #3 (cont.) We get some sort of “implicit concurrency”,

    it’s totally deterministic and free of any hussle
  9. qs [] = [] qs (p:xs) = (qs l) ++

    [p] ++ (qs g) where l = filter (< p) xs g = filter (>= p) xs Haskell Quicksort
  10. qs [] = [] qs (p:xs) = (qs l) ++

    [p] ++ (qs g) where l = filter (< p) xs g = filter (>= p) xs Haskell Quicksort
  11. qs [] = [] qs (p:xs) = (qs l) ++

    [p] ++ (qs g) where l = filter (< p) xs g = filter (>= p) xs Haskell Quicksort
  12. qs [] = [] qs (p:xs) = (qs l) ++

    [p] ++ (qs g) where l = filter (< p) xs g = filter (>= p) xs Haskell Quicksort
  13. qs [] = [] qs (p:xs) = (qs l) ++

    [p] ++ (qs g) where l = filter (< p) xs g = filter (>= p) xs Haskell Quicksort