Comment Erlang and other functional languages (Score 1) 342
I must concur with the opinion about erlang (or more generally, functional languages) and parallel programming.
IMO the most important feature which functional languages have and proceedural don't have which make them appropriate for parallel programming is single assignment. That is once 'X' is assigned a value it can never change. This means that sharing 'X' with other threads is a no-brainer, because nothing can go wrong.
You are forced by the languages to specially type (in Haskell) or access (dictionaries in Erlang) those variables which are going to hold shared state. Shared state is not the default like it is in C, java, etc... .
This means many fewer mistakes, especially with multiple developers reusing code, because you can easily see in the source code which variables are shared and need special access.
The down side of single-assignment is memory usage. If you are indeed looping (recursing) and doing it in such a way that the compiler cannot optimize away the old X, you rapidly use up heap space storing every new X. This uses O(N) space, rather than O(1) like the change-X-in-place C code would, and that puts pressure on the caches and the memory bus. Hopefully the memory bandwidth will continue to scale with the # of cores.
The other features needed for parallel programming are a green-threads (userspace-threads) and light weight message passing. But you achieve those just as well in C with a library or a bit of code.
IMO the most important feature which functional languages have and proceedural don't have which make them appropriate for parallel programming is single assignment. That is once 'X' is assigned a value it can never change. This means that sharing 'X' with other threads is a no-brainer, because nothing can go wrong.
You are forced by the languages to specially type (in Haskell) or access (dictionaries in Erlang) those variables which are going to hold shared state. Shared state is not the default like it is in C, java, etc... .
This means many fewer mistakes, especially with multiple developers reusing code, because you can easily see in the source code which variables are shared and need special access.
The down side of single-assignment is memory usage. If you are indeed looping (recursing) and doing it in such a way that the compiler cannot optimize away the old X, you rapidly use up heap space storing every new X. This uses O(N) space, rather than O(1) like the change-X-in-place C code would, and that puts pressure on the caches and the memory bus. Hopefully the memory bandwidth will continue to scale with the # of cores.
The other features needed for parallel programming are a green-threads (userspace-threads) and light weight message passing. But you achieve those just as well in C with a library or a bit of code.