3 ms·
Yeah they mention that in 2 of the 6 points arguing in favor of behaviors: 2. The application programmer writes sequential code, all concurrency is hidden away
by wefarrell 4y ago
Yeah they mention that in 2 of the 6 points arguing in favor of behaviors:
2. The application programmer writes sequential code, all concurrency is hidden away in the behaviour;
4. Easier for new team members to get started: business logic is sequential, similar structure that they might have seen before elsewhere;
- sb8244 4y agoThanks for that. My thought is probably just semantics then. I think it's even more nuanced, but doesn't really matter for this type of post. (I am actively writing a chapter exploring this topic, so is has been top of mind.)
- toast0 4y agoAdding on to sb8244's comments; writing sequential code is very nice, but it's not the gen_server behavior that gets you that. It's the lightweight processes. gen_server is useful, but it's not much more than receive in a tail recursive loop and conventions around messages, most specifically about if the sender expects to receive a reply or not. It's not magic, and it's written in clear Erlang that anyone with a week of Erlang fiddling can understand (which kind of is magic; almost everything in OTP is clearly readable) Concurrency comes from running many processes each with their own message queue.