Brian's Functional Brain
blog.bestinclass.dk
blog.bestinclass.dk
This is why I am still wary of adopting these languages with "fixed memory". Ok for a cellular automaton there happened to be a workaround, but in general, isn't all data connected somehow? So how does one handle that in a big system with lot's of data? I can not change ALL data in every iteration. (Specific example: suppose I want to write a multiplayer game server - for every move a player makes, I would have to replace ALL game objects, player object, and so on???).
I looked a bit into Erlang and it seems there could be a workaround by having lots of threads, so one only needs to change the dataset of one thread at a time. But how do Clojure or Haskell handle that kind of thing (I don't think they encourage thousands of threads as Erlang does?).
I think erlang also had a special kind of data structure that would also allow for kind of mutable data per thread, but really, it all sounded a bit messy to work with.
How does the paradigm hold up anyway? Isn't there one point eventually when the processes still interfere with each other? For example when accessing the database?
That said... multidimensional arrays continues to be a sore point with functional programs, as far as I know. A variety of purely functional structures exist that can replicate some parts of the performance guarantees of traditional arrays, but I am not aware of anything that can cover the full gamut of uses for a multidimensional array. Usually in this case there is a functional structure that does what you really need, but ISTM that when you find yourself needing a multidimensional array, it's because A: it's huge B: you need fast O(1) updating and C: you need fast O(1) access and that combo is just killer. (And nowadays, D: you need cache coherence control comes up too.)
Oh, and if I'm reading your question correctly, Erlang process isolation is not really related to your question. However, I will point out that in Erlang, two processes will not access the database "at the same time". Two processes will send messages to the database Erlang-process, which will serve them in order and send back the replies. When processes and messaging are cheap you change how you do things; a lot more things get wrapped in processes (files, socket connections, foreign libraries, pipes to externally running programs ("ports" in Erlang speak, rather unfortunately), etc.) than you'd expect. It's the fundamental primitive for avoiding contention, it gets used a lot!
The first half is sort of a description of the Clojure philosophy, the second half is building an ant simulation very similar to this game of life but with STM instead.