threads. • Processes share nothing with each other. • Erlang can support millions of processes running at the same time. • Feels like Ruby objects (well defined)
cost Cheap, maximum is 134,217,727 Cheap, everything is an object How to communicate with each others? Asynchronous message passing Synchronous messaging passing
for bob.how_is_sushi? Process:<0.35.0> {receiver, method, arg, env, sender} Process:<0.36.0> {receiver, method, arg, env, sender} spawn new process for bob.sushi_score
talk. • Alice: Do you like the sushi today? • Alice starts waiting Bob’s response • Bob receives the message, starts thinking how to respond in Japanese. • Bob: Sushi wa umai desu. • Alice receives the message, starts thinking what to say next.
receiver, which will set self as default receiver • For example: puts “hello world” is invoking puts on self with argument “hello world”, without typing self
• Bob waits for Alice to Talk. • Alice ask Bob: is_sushi_good? • In Bob receive block, receive the message, send message “sushi_score” to self(Bob), then waiting Bob to respond. • Bob can’t receive the “sushi_score” message because he’s already in a receive block, Bob waits forever, program hanged.