Hacker News new | ask | show | jobs
by wefarrell 1243 days 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;

2 comments

Adding 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.

Thanks 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.)