1998Q1/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: Re: [MUD&#45;Dev]  Dynamic Loading of Modules (was: Back on the list) -->
<!--X-From-R13: Hnqvz Fxnpuraxb <inqvzgN4pf.pbz> -->
<!--X-Date: Tue, 24 Feb 1998 08:42:44 +0000 -->
<!--X-Message-Id: 34F28806.9068CF9A#4cs,com -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: Pine.SOL.3.96.980224080855.19470A&#45;100000#licia,dtek.chalmers.se -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, Re: [MUD-Dev]  Dynamic Loading of Modules (was: Back on the li</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:vadimt#4cs,com">
</head>
<body background="/backgrounds/paperback.gif" bgcolor="#ffffff"
      text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000">

  <font size="+4" color="#804040">
    <strong><em>MUD-Dev<br>mailing list archive</em></strong>
  </font>
      
<br>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
<br clear=all><hr>
<!--X-Body-Begin-->
<!--X-User-Header-->
<!--X-User-Header-End-->
<!--X-TopPNI-->

Date:&nbsp;
[&nbsp;<a href="msg00574.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00577.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00574.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00764.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00575">Author</A>
&nbsp;|&nbsp;<A HREF="#00575">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00575">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>Re: [MUD-Dev]  Dynamic Loading of Modules (was: Back on the list)</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: <A HREF="mailto:mud-dev#null,net">mud-dev#null,net</A></LI>
<LI><em>Subject</em>: Re: [MUD-Dev]  Dynamic Loading of Modules (was: Back on the list)</LI>
<LI><em>From</em>: Vadim Tkachenko &lt;<A HREF="mailto:vadimt#4cs,com">vadimt#4cs,com</A>&gt;</LI>
<LI><em>Date</em>: Tue, 24 Feb 1998 02:42:46 -0600</LI>
<LI><em>Sender</em>: <A HREF="mailto:vt#vadimt,4cs.com">vt#vadimt,4cs.com</A></LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>
Niklas Elmqvist wrote:
&gt; 
&gt; On Mon, 23 Feb 1998 coder#ibm,net wrote:
&gt; &gt; On 20/02/98 at 12:43 AM, Niklas Elmqvist &lt;d97elm#dtek,chalmers.se&gt; said:
&gt; &gt; &gt;Nothing sensational,
&gt; &gt; &gt;it's all been done before, but I could outline my little scheme here if
&gt; &gt; &gt;there is interest.
&gt; &gt;
&gt; &gt; Please do.
&gt; 
&gt; Okay, here goes...
&gt; 
&gt; As I said earlier, I am aiming to decouple the actual core server from
&gt; the world processing routines. Ideally, the main server would not even
&gt; *know* it is running a MUD, it would be sort of a general-purpose core,
&gt; and all the functionality such as DB management, socket I/O and AI would
&gt; be implemented in free-standing modules separate from the main executable
&gt; (at least, I envisioned this in the beginning). I mentioned this to a RL
&gt; friend of mine, and he pointed out that it all sounded very much like
&gt; conventional OS architecture, especially like the module system of Linux
&gt; kernels. I studied these a bit and learned some good stuff about dynamic
&gt; loading (or linking), and then started experimenting with using DL
&gt; together with C++. The results can be found at
&gt; &lt;URL:<A  HREF="http://artoo.hemmet.s-hem.chalmers.se/~crozius/resources.html">http://artoo.hemmet.s-hem.chalmers.se/~crozius/resources.html</A>&gt;, but I
&gt; will outline it briefly here as well.
&gt; 
&gt; In essence, what I discovered (to myself, that is, this is no doubt old
&gt; news to some people) was that I could compile the core server with a base
&gt; class with very little functionality, call it aClass, which called a
&gt; factory function in a shared library, returning a pointer to an aClass
&gt; object. Then, in the actual shared library (which is linked in with the
&gt; main binary at run-time) I instead return an instance of a class
&gt; called bClass, which inherits from aClass but which is totally unknown to
&gt; the core server. Best of all, it works! That is, when I call the Execute()
&gt; member function on the aClass handle in the core (which, unbeknowst to the
&gt; core, points to a bClass object with redefined Execute() function), the
&gt; correct Execute() function is called, that is bClass::Execute().
&gt; 
&gt; Now, if aClass and bClass had been part of the same binary, I would not
&gt; have been surprised. In fact, as you probably all know, this is called
&gt; late binding in the O-O community and is an important feature of all
&gt; serious O-O languages. However, what surprised and delighted me is that
&gt; late binding *still* works even though the core and shared lib described
&gt; above are separately compiled, and the bClass is totally unknown to the
&gt; core! In my eyes, this is the ultimate test of late binding, and G++
&gt; pulled it off nicely! Incidentally, a friend (the one mentioned above)
&gt; later reported that this is impossible in Windows-style DLLs.
&gt; 
&gt; If you are wondering what the fuss is all about (or why this posting is
&gt; getting so long), let me just say this: One application of this could be
&gt; an Event class (in an event-driven system), whose base class is known to
&gt; the core server (allowing for it to check the priority and expiration of
&gt; the event, among other things), while the modules can inherit from the
&gt; base class and redefine it to suit their particular needs. I also plan on
&gt; using this technique for Handler objects which take care of things such as
&gt; socket I/O, parsing, DB managment, etc, and the good thing about it is
&gt; that I thus will be able to attach and detach the modules at run-time (to
&gt; remedy a bug, for example). If the base classes are correctly implemented,
&gt; the core will never even have to be recompiled and thus never rebooted
&gt; (not accounting for fatal bugs, that is &lt;g&gt;)!

Not quite so. 

See,  I use almost exactly the same technique in my Java development,
and indeed, it's possible, using Class.forName( ... ), instantiate the
absolutely unknown before classes - in fact, I suspect that the other
guy, who lives at <A  HREF="http://www.wwwalker.com/">http://www.wwwalker.com/</A>, used this technique to
produce applets at least a year ago, but his technique seems to be even
more pervert - he compiles classes on-demand, and then actually loads
them.

The weak point for me is that once you load the class, it's extremely
difficult to UNLOAD it. 
I've heard that the guys who write the servlet support for Apache
managed to write the custom ClassLoader to do that, but didn't have time
to dig it myself.

How do you handle this?

&gt; Whew. Sorry if I babbled on a mite too much, but I hope this will be of
&gt; some use to someone.

I really like this way too.

&gt; -- Niklas Elmqvist (d97elm#dtek,chalmers.se) ----------------------

-- 
Still alive and smile stays on,
Vadim Tkachenko &lt;VadimT#4CS,Com&gt;
--
UNIX _is_ user friendly, he's just very picky about who his friends are

</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00574" HREF="msg00574.html">Dynamic Loading of Modules (was: Back on the list)</A></STRONG>
<UL><LI><EM>From:</EM> Niklas Elmqvist &lt;d97elm#dtek,chalmers.se&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00574.html">Dynamic Loading of Modules (was: Back on the list)</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00577.html">Re: [MUD-Dev]	BOOK: Myer's Silverlock</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00574.html">Dynamic Loading of Modules (was: Back on the list)</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00764.html">Re: [MUD-Dev] Dynamic Loading of Modules (was: Back on the list)</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00575"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00575"><STRONG>Thread</STRONG></A></LI>
</UL>
</LI>
</UL>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
<ul><li>Thread context:
<BLOCKQUOTE><UL>
<LI><strong><A NAME="00540" HREF="msg00540.html">Re: [MUD-Dev]	Back on the list</A></strong>, 
Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Fri 20 Feb 1998, 16:16 GMT
<LI><strong><A NAME="00533" HREF="msg00533.html">Back on the list</A></strong>, 
Niklas Elmqvist <a href="mailto:d97elm#dtek,chalmers.se">d97elm#dtek,chalmers.se</a>, Fri 20 Feb 1998, 08:38 GMT
<UL>
<LI><strong><A NAME="00564" HREF="msg00564.html">Re: [MUD-Dev]  Back on the list</A></strong>, 
coder <a href="mailto:coder#ibm,net">coder#ibm,net</a>, Mon 23 Feb 1998, 19:13 GMT
<UL>
<LI><strong><A NAME="00574" HREF="msg00574.html">Dynamic Loading of Modules (was: Back on the list)</A></strong>, 
Niklas Elmqvist <a href="mailto:d97elm#dtek,chalmers.se">d97elm#dtek,chalmers.se</a>, Tue 24 Feb 1998, 08:19 GMT
<UL>
<LI><strong><A NAME="00575" HREF="msg00575.html">Re: [MUD-Dev]  Dynamic Loading of Modules (was: Back on the list)</A></strong>, 
Vadim Tkachenko <a href="mailto:vadimt#4cs,com">vadimt#4cs,com</a>, Tue 24 Feb 1998, 08:42 GMT
</LI>
<LI><strong><A NAME="00764" HREF="msg00764.html">Re: [MUD-Dev] Dynamic Loading of Modules (was: Back on the list)</A></strong>, 
J C Lawrence <a href="mailto:claw#under,engr.sgi.com">claw#under,engr.sgi.com</a>, Thu 19 Mar 1998, 19:42 GMT
<UL>
<LI><strong><A NAME="00787" HREF="msg00787.html">Dynamic Loading of Modules</A></strong>, 
Niklas Elmqvist <a href="mailto:d97elm#dtek,chalmers.se">d97elm#dtek,chalmers.se</a>, Fri 20 Mar 1998, 11:39 GMT
<UL>
<LI><strong><A NAME="00797" HREF="msg00797.html">Re: [MUD-Dev] Dynamic Loading of Modules</A></strong>, 
Greg Munt <a href="mailto:greg#uni-corn,demon.co.uk">greg#uni-corn,demon.co.uk</a>, Fri 20 Mar 1998, 21:53 GMT
</LI>
<LI><strong><A NAME="00850" HREF="msg00850.html">Re: [MUD-Dev] Dynamic Loading of Modules</A></strong>, 
J C Lawrence <a href="mailto:claw#under,engr.sgi.com">claw#under,engr.sgi.com</a>, Mon 23 Mar 1998, 19:14 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</LI>
</UL></BLOCKQUOTE>

</ul>
<hr>
<center>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
</center>
<hr>
</body>
</html>