Erlang (was: Re: Generics)

Eric Merritt cyberlync at yahoo.com
Mon Nov 10 19:52:23 UTC 2003


I am a big erlang fan an thought I would chime in.

> I've been reading up on Erlang myself. They have an 
> approach where everything is a process and you send 
> messages to these processes. Just imagine having a 
> separate process for each Squeak object. 

 I don't see a need for every object to be a process,
but it would be nice to have extremely cheep process
creation and a preemptive thread model.

> They argue that processes should be as easy to 
> create as objects. 
 
 Actually, they argue that processes should be as
cheap as possible to create and as simple as possible
to use.  They have basically accomplished this well.
Its not unusual to have hundreds of thousands of
processes ruining in the same VM. Recently they have
even started talking about millions of processes in a
VM on the erlang list.

> You would think this would 
> kill performance, but actually, the systems they 
> have written in it scale very well (the web 
> server they wrote in Erlang can handle 10x the 
> capacity of a Apache server, if I remember 
> correctly). 

 This is not just due to the fact that processes are
cheap and easy. Its due also to the OTP design
principles that are advocated widely in the erlang
community. Processes do give a very nice conceptual
foundation to work from though, they also make things
like web servers pretty easy to use.

btw, the webserver you are talking about is hosted at

http://yaws.hyber.org/

The report on thier benchmarking against apache is
here

http://www.sics.se/~joe/apachevsyaws.html


> They also boast numbers of 99.99999% 
> availablity for the Ericsson switch that was 
> written in mostly Erlang. Now, those boasts 
> are what got me interested. It is a functional
> language and they are big on no mutable state 
> like most functional languages. They argue 
> that Erlang makes multi-processing easy and in 
> fact easier than single process systems.

 Multi-threading is easy because no process has direct
access to another processes state. You can only send
messages to and receive messages from a process. Those
messages get queued up in a mailbox and are processed
one by one. This gets rid of things like semaphores,
mutexs, etc that makes multiprocess programing in the
mainstream world so difficult.
 
> They seem very anti-OO on their list, but I 
> have found that the whole process thing maps 
> very well to objects. But, I haven't gotten that 
> far. It just seems they have been scarred by 
> the {} crowd and static typed OO systems.

 Much of the functional crowd is anti-oo, or more
specifically very pro-functional. I think this is due
to the fact that many OO advocates are very combative
and annoying when proselytizing OO. In reality both
are very nice paradigms that could learn allot from
one another.

> I haven't had a whole lot of time to really get much

> deeper than that. I bought the book and have 
> been working through some of the examples. They 
> do  a lot with pattern matching and it's made 
> me think about certain programming topics 
> differently.

  Pattern matching just rocks. I think it simplifies
quite allot of things. Unfortunately I dont really see
how it could work in an OO language.

 Just to close up, I would love to see squeak adopt
some things from erlang. Following is a list.

 1) Erlang style message passing.
  This could probably be implemented in Squeak right
now without any problems. What you wouldn't get is the
message processing via pattern matching. You also
couldn't make sure that you only processed messages
coming from the local mailbox. 

 2) Cheap preemptive multi-threading.
   From what I understand from previous discussions on
this list, this would be a major undertaking requiring
big changes to the VM and massive refactoring of
existing code. That being the case I don't see this
happening anytime soon.

 3) Transparent non-blocking IO.
  All IO in erlang is non-blocking (this may not be
the case for linked in drivers). Basically this is
completely transparent to the erlang programmer. The
system takes care of starting and stooping a process
that can't read or write data. I know so little about
the Squeak IO system that I can't really comment on
the relevance of this to Squeak.

 4) Pattern Mathian.
  Maybe its my limited imagination, but I just don't
see how this is even possible in an OO language.

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree



More information about the Squeak-dev mailing list