[erlang-questions] A couple of design questions

Ulf Wiger ulf.wiger@REDACTED
Fri Mar 27 11:22:31 CET 2009


mats cronqvist wrote:
 >
>   Oldtimers avoid the process dict because it used to be slow.
 > "Real" functional programmers avoid both ets and the dict
 > for religious reasons.  AFAIK, there's no real reason to
 > avoid the process dict in favor of ets.

I agree, sort of. I've argued before that the process
dictionary is better than its reputation suggests. (:

There are some different tradeoffs, though:

- No GC on ets data, but data in the process dict will
   be subject to GC. Good or bad depending on how you
   look at it.
- Objects in the process dict will be included in a
   crash report, while objects in ets will simply go
   away silently. Good or bad depending on your needs.
- No copying when accessing the PD, while ETS accesses
   always copy (except large binaries, of course).
   The fact that the PD is GC:d will to some degree cancel
   out this advantage.
- No lock contention when accessing the PD. Not sure
   exactly how this looks when other processes try to
   peek at your PD, but please don't use that for anything
   but debugging. (:

In Steve's case, I guess there are no significant
disadvantages in using the PD over ETS.

BR,
Ulf W
-- 
Ulf Wiger
CTO, Erlang Training & Consulting Ltd
http://www.erlang-consulting.com



More information about the erlang-questions mailing list