On Fri, 16 Mar 2012, Vasily Chekalkin wrote: > 2. Erlang is immutable language with Message Passing architecture. It's > _always_ safe to split execution into different thread, process, server in > this case.
</lurk> This is something that has been bugging me about the direction of Perl 6 for a few years. The relationship between immutability and implicit thread safety has been well known for a very long time: I was reading old research papers about it in 1989, and while the trend towards generation of code at runtime has opened new opportunities for inferences, those are really complicated, hard to get right, and dependent on language features that we've brushed aside in designing Perl 6. There seems to be an assumption (in P6) that auto-threading is only of interest is when the programmer has signalled that it's OK, either through eigentypes, or using vector constructs like "map". There's a bunch of hand-waving towards "detecting when parallelism is possible", but I fear that won't get far in practice. Analysis at compile time an NP-complete problem; doing it at runtime is still NP complete but has a greater chance of finding stuff, at the expense of having to re-run when immutability can't be proven; and "map" and eigenvalues aren't used much in real-life programs. We should be able to do much, MUCH better: parallelism should be the default, all the time. But to get there, we need a language and a VM that makes "doing it right" easier than "doing it wrong". * For the language that means making declaring & using a "constant" easier (more concise) than a "variable". * For the VM that means enabling the despatch mechanisms to see whether a PMC represents a mutable container or an immutable value, and assisting constructors to switch off mutability once initialization is complete. Folk worry that complicated despatch mechanisms are too costly, but I think such concerns are short-sighted. Going 60% slower on a single core might seem like a big loss, but as soon as you can utilize 3 or more cores, you're ahead, and by 10 cores you're at quadrupal speed single-core speed. For several years chip manufacturers have been shipping sample quantities of CPUs with many tens of cores. By the time that Perl 6 comes to mainstream, even mobile phones are likely to have upwards of a eight cores; it would be a great shame if the "ordinary" Perl 6 program won't be able to use them. -Martin <lurk> _______________________________________________ http://lists.parrot.org/mailman/listinfo/parrot-dev
