gen_tcp:controlling_process

Wiger Ulf ulf.wiger@REDACTED
Sun Mar 2 22:24:54 CET 2003


From: "Joakim G." <jocke@REDACTED>

> Personally I think that the recommendation to new Erlang users to use
> the gen_server is a disaster. At least when it comes to the growth of
> the Erlang user base. They just get the wrong impression on how we
> recommend "real" Erlang code to be written.
>
> When I discuss this with Martin B. (one of the people behind OTP)
> he usually points at me [like Uncle Sam in the famous president
> campaign poster] saying: "So you want us to copy&paste common code in
> order to write a new server?". I just have to say yes.

Of the various ideas I've had during the AXD 301 project, suggesting that
we'd use "classic servers" for the call handling code was one of the
dumbest, and I had to take that back later.

In those early days, gen_server wasn't all that fast, and we were looking
for any performance advantage we could get. Thus, in order to shave off some
50 us per call, "we" (mostly I) decided that gen_server was unneccessary
overhead for performance-critical processes, and it wasn't that difficult
after all to write those servers from scratch. So I made an example server
and people could copy it.

It didn't work out well. We did get some measurable (but not more)
performance improvement, but we also got measurably more bugs in our system.
After a while, we wrote it off as a bad idea and went back to gen_servers.

So my advice to newcomers, based on past mistakes: use gen_server.

Those of you who get hooked on the language and play around enough to
eventually discover the Erlang Philosophy, will eventually be able to roll
your own and (perhaps) leave gen_server behind you. Personally, I use
gen_server a lot still. I've had my ups and downs with it, but we always
make up eventually.

/Uffe




More information about the erlang-questions mailing list