Tag Info

New answers tagged

3

Short answer in two words: OBSERVABLE NONDETERMINISM Long answer: It depends on which approach to concurrent programming you use given your problem. In the book Concepts, Techniques, and Models of Computer Programming, authors clearly explain four main practical approaches to writing concurrent programs: Sequential programming: a baseline approach that ...


0

The hardest part of writing parallel code is to stop one thread from reading data that is being updated by anther thread. A common solution to this is to use immutable objects, so that once an object is created it is never updated. But in real life data has to be change, therefore “persistence” data is used, where every update returns a new object – ...


0

Pure functional code is thread-safe by default. That, by itself, is already a huge win. In other programming languages, designing blocks of code that are completely thread-safe can be really, really challenging. But a pure functional language forces you to make everything thread-safe, except in the few places where you explicitly do something that's not ...


2

Lets first look at why procedural programming is so bad at concurrent threads. With a concurrent programming model, you are writing sequential instructions that (by default) expect to be run in isolation. When you introduce multiple threads, you need to explicitly control access to prevent concurrent access to a shared variable when those changes may ...


48

The main reason is that referential transparency (and even more so laziness) abstracts over the execution order. This makes it trivial to parallelize evaluation. For example, if both a, b, and || are referentially transparent, then it doesn't matter if in a || b a gets evaluated first, b gets evaluated first, or b doesn't get evaluated at all (because a ...


3

Minimised shared state What is it about functional programming that makes it inherently adapted to parallel execution? The pure nature of the functions (referential transparency), i.e. having no side effects, leads to fewer shared objects and hence less shared state. A simple example is; double CircleCircumference(double radius) { return 2 * 3.14 * ...



Top 50 recent answers are included