Advantages of a large number of threads cf other approaches?

Shawn Pearce spearce@REDACTED
Mon Feb 16 23:38:27 CET 2004

I'm currently building a windows serial port driver for Erlang.
(I'll post a link to the source to this list in a day or two.)

Its a mess compared to native Erlang code.  Because the serial ports
on Windows are blocking, life gets ugly fast.  But in Erlang a
blocking operation would just cause you to spawn a new process and
keep that blocking operation in its own seperate execution context.

I'm basically rebuilding the erts event loop, just in an external port
program.  It really stinks.

Erlang rules.  :-)

I totally agree with every comment everyone else has said on this topic,
especially Joe's point about processes being able to crash and not
affect others.  OTP is really powerful in being able to monitor the
crashes and take automatic corrective action.

I have yet to see any other toolkit that does this as well as Erlang/OTP
does.  Even Java doesn't seem to offer the same stability, performance
and ease of development, error trapping, and error recovery.

I'm wodering how I can go back to my day job tomorrow after a week of
vacation and several days of Erlang hacking.  I write Java for a
living.  :-(

jonathan@REDACTED wrote:
> I was discussing Erlang with a colleague and little difficulty 
> convincing him either that its CSP approach was superior to trying to 
> manage a large number of threads using semaphores, or that Erlangs VM 
> threads scale better than antive threads on the OS's we're familiar 
> with. What I had a harder time doing was convincing him that using a 
> large number of threads was a best solution for any of the major 
> cases we discussed:
> * Internet servers - why not use asynchronous sockets running in a 
> single thread?
> * Simulations - why use an object per thread rather than a "classic" 
> OO approach?
> One answer is that CSP threads (at least in the first case) lead to a 
> simpler design and that Erlang itself has a host of features that 
> support highly reliable programs. But I'd appreciate suggestions 
> regarding other benefits, especially those arising from CSP itself.
> - Jonathan


  The only function of economic forecasting is to make astrology look respectable.
  		-- John Kenneth Galbraith

More information about the erlang-questions mailing list