On 30 сен, 12:03, Ben Harris <
bharri...@gmail.com> wrote:
> If you aren't operating on a consistent version of the memory, your
> application behaviour is undefined.
Oh, so your ambition is to combine concurrency and strictly defined
behaviour? So far nobody has achieved that kind of thing in a
practical
world. Even Haskell programs have to use states and C libraries once
in a while.
> Node 1 has x = 0, Node 2 has y = 0
> Operation 1 is
> if(x != y) while(true)
> Operation 2 is
> y++; x++
>
> If they both start at the same time then Operation 1 will get in to an
> infinite loop.
Variables "x" and "y" is a state.
You programmed your operation such that in a certain state it will
go into infinite loop. It would do the same without concurrency.
Concurrency only introduces the possibility that state will be
different.
> Concurrency is not a simple thing.
>
> Also, what are the side effects of deflate on string? You should put
> String in and get String out. What side effects are there?
You and I know that there's virtually no side effects
(apart from linking into C library, allocating memory with malloc,
etc. - but we can still mark the operation as one without side effects
and nobody would know better),
however, the language does not know, it can not *prove* that calling
ZIP algoritm, which is essentially not pure, it does not violate
its safety constrains. So, if you would try to enforce safety on the
language level, you would essentially ban users from effectively using
existing stateful algorithms such as ZIP.
> Scala has a
> large number of immutable data structures. Also, when I say side-
> effects, I am thinking more about file operations, network operations,
> etc.
Exactly what I mean.
Here I want to call "unrar" program to unpack my string,
or call a C library on my data,
or such simple thing as scanning application logs on multiple servers,
using memory mapped buffers, and gather results using Swarm.
Practically everything in imperative programming world have side
effects, from the point of view of a purely-functional compiler. What
I say is that to be practical, Swarm should allow such computations on
local data. Trying to limit it to operating on a closed set of data
structures will make it next to useless at least to me.