You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Roger Espel Llima <es...@iagora.net> on 2000/06/12 19:23:03 UTC

Re: perl vs java

Gunther Birznieks <gu...@extropia.com> wrote:
> 2. Would you write a chat engine in Perl? I wouldn't! (Well, actually I did 
> 5 years ago but I am certainly not proud of that code).

I did, just a few months ago, and it's working very nicely.

> The thing about a real-time chat engine is the same issue as #1, it is 
> really inefficient resource-wise to flush messages to a persistent data 
> store or even using IPC shared memory in Perl in order to allow all the 
> Perl processes to share a common list of chat messages even if only for the 
> last 5 minutes worth of chat.

So don't do it like that :)  My chat engine is a single-threaded,
select()-based plain Perl daemon (no apache there) that takes http
connections on a non-standard port, directly from the browser, and keeps
them open for as long as the browser will.  It speaks http on one end,
and uses the irc-server-to-server protocol to talk to an ircd on the
other.

Technically, yeah, select() is arguably ugly, but if you wrap it around
OO classes for the various kinds of buffers and connections, it's all
quite manageable.

Chat connections are very low bandwith, and a single-threaded design
tends to be memory effective, so I'd expect this setup to handle a few
hundred simultaneous users easily.  If you want more, use a standard irc
daemon as a hub, and connect several such perl servers to it; if you
want to have a java applet client too, it can talk directly to the irc
server.

-- 
Roger Espel Llima, espel@iagora.net
http://www.iagora.com/~espel/index.html