you work as a programmer for a company. On Monday, you’re given two different tasks and they must be completed in two days. You can finish the first task on the first day and you can finish the second task on the second day.
- You Day 1 - Her Or your boss hires another programmer, and you can alternate between the two tasks when she is doing the same. You will get both tasks done by the end of the first day.
Day 2 Concurrent The second way of doing things is concurrent. You’ve split the tasks in halves and alternate between the two, anyway you want it. This way, there isn’t much gain when talking about time, but this brings us to the third way....
- You Day 1 - Her Parallel The third way of doing is the real deal. Because you’ve split a bigger task in indipendent pieces, bringing another programmer in will actually make things faster, getting the two tasks done by the end of day 1. This is a classic example and also an oversemplification of the problem, but it’s just for the sake of explaining it.
is actually the composition of indipendent pieces of work to be done, or in the programming domain, it is the composition of indipendently running things
way the system composes your threads, you cannot know the order in which they are executed. In addition, your thread can get interrupted at any time to let other threads grab a share of the CPU. If you previously had one path of execution, now you have a freaking lot.
program. This leads to a large family of problems. Multiple threads may want to access and change shared memory. This is bad. Your program will not crash, but your data will be wrong. You have to handle synchronization between threads so this stuff will not happen.
but to me this feels freaking hard. Not only do I have to think about getting the Task done, I even have to handle all the coordination between threads and their synchronization, otherwise the whole thing will explode right in my face. This is exactly why so many people give up threads. They not only give up, they even build enormous runtimes where everything is run a single thread, so they don’t even have to think about it.
#1 Msg #2 ... Yes because actors talk to other actors using messages. In each actor there is a loop which consumes these messages and do the work. Messages are either synchronous or asynchronous, meaning that when sending synch messages the actor will be blocked until it receives an answer, asynch messages instead are like fire and forget, the actor sends them and goes on with its work.
with a fantastic community around it, maybe the best community. It would pain me if in 5 to 10 years I'd be forced to move away because it could not keep up. Fortunately people before me realized the exact same thing. So they've put and are putting a tremendous effort in building alternative runtimes with parallelism in mind from the first day of development. JRuby is very mature at the moment, but as it has been built on the JVM, its support for native gems (gems written in C or C++) is non existent. On the other hand Rubinius is still a work in progress. It is ready and is being used in production, but does not work 100% with Rails. The effort and contributions toward these two project are an investment in the future of Ruby so that in 5, 10, maybe even 20 years we could still be using our favourite language for getting the Task done.