1999Q4/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: Re: [MUD&#45;Dev] Embedded languages, object persistance... ack. -->
<!--X-From-R13: ptNnzv&#45;pt.UenlEntr.Sqzbagba.OP.QO -->
<!--X-Date: Wed, 29 Dec 1999 21:09:01 &#45;0800 -->
<!--X-Message-Id: 199912300400.VAA10182@ami&#45;cg.GraySage.Edmonton.AB.CA -->
<!--X-Content-Type: text/plain -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, Re: [MUD-Dev] Embedded languages, object persistance... ack.</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:cg@ami-cg.GraySage.Edmonton.AB.CA">
</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="msg00792.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00794.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00839.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00782.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00793">Author</A>
&nbsp;|&nbsp;<A HREF="#00793">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00793">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>Re: [MUD-Dev] Embedded languages, object persistance... ack.</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Subject</em>: Re: [MUD-Dev] Embedded languages, object persistance... ack.</LI>
<LI><em>From</em>: <A HREF="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</A></LI>
<LI><em>Date</em>: Wed, 29 Dec 1999 21:00:03 -0700</LI>
<LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Sender</em>: <A HREF="mailto:mud-dev-admin#kanga,nu">mud-dev-admin#kanga,nu</A></LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>
[Joe Kingry:]

[The old-timers on the list would likely have guessed that this is the
kind of question that would get a response from me, since I'm known to
be a programming-language geek!]

&gt; I want a mud server on which I can change the code online of say a skill, a
&gt; spell or something else. I understand that this is the purpose of having an
&gt; embedded language that runs "on top of" the mud's driver. i.e. MUF for MUQ,
&gt; Python for AR3 etc.  So in general I know this code is to be compiled since
&gt; you don't want to be executing "scripts", but is this code an object? and
&gt; then is the byte-code stored? ack.. I'm confused.

As previous responders have indicated, note carefully that what I say
here is what *I* think, and by no means the best or only answer. You
can read far more than you want about my system at:

    <A  HREF="http://www.graysage.edmonton.ab.ca/cg/MUD/AmigaMUD">http://www.graysage.edmonton.ab.ca/cg/MUD/AmigaMUD</A>

(I still call it AmigaMUD even though I'm totally on Linux now - I need
a new name, updated images, updated docs, etc.).

There have been technical papers on the idea of a "persistent programming
language" for several years now. The earliest I know of is APL, which used
"workspaces" on IBM mainframes in the 70's. The basic idea is that if you
write an assignment statement like:

    name := "Fred";

then the variable 'name' will keep that value over reruns of the system,
and even reboots of the computer. Given that, and more complex types in
the language, you can produce a distinctly different style of programming
environment. Such a programming language can be extremely useful in a
MUD system, especially if the language and its environment is also customized
for MUD-type activities.

Note that the above viewpoint is a very programming-language-centric one.
The main concern here is the MUD, and a persistent programming language is
just one possible tool for building the MUD. From a language point of
view, the alternative to being a persistent language is to require
explicit I/O calls of some kind in order to achieve the persistence.
That certainly works, but can be more of a pain to program in.

Is there such a language, and persistence system (whether it be an actual
database or something written specifically for that language system)
freely available? I dunno. Sorry about that. Since half the fun of doing
my MUD system was writing the persistent language, I wasn't motivated to
go looking!

Does such a language have to be a lot slower than other "more standard"
languages? It depends. There is overhead in being persistent, but that
overhead can be less than other overheads that are possible in the choice
of language features. So, there can be persistent languages that are
faster than many (perhaps even most) non-persistent languages.

&gt; All I want in a mud server is this:

&gt; An added bonus would be, but hardly nessesary:
&gt; -driver ported to both Win32 platform and *nix platforms and database is
&gt; independent of platform.

My system does all of those except the HTTP access. I'm not sure what
that would mean in many cases. How do I convert a list of references to
bytecode streams into something to display on a web page? I haven't
actually ported my main server to Windows, but the port wouldn't be
very hard. If you stay away from any GUI or MFC things, and stick to
the non-asynchronous socket stuff, you should be mostly OK. Oh, and
don't use Windows threads or Windows messages, either.

How does it all work and fit togother? I went looking at my online docs
a bit, and nothing explains it too clearly, so I'll give it a go here.
I'll start at the lowest levels and work up from there.

My "database" was build for the MUD system. It does not store traditional
records or tables at all. Instead, it stores "characters", "grammars",
"things", "actions", "strings", "lists", "tables", etc. These are of varying
lengths, and some, like "lists" and "things", change their lengths at times.
Each entity in the database has a unique 32 bit key. Part of that key
is a direct index into the contents of the "MUD.index" file. That yields
a short descriptor of the entity, giving the size of the slot it currently
occupies, the amount of space it currently uses, and the offset of the
actual data in the "MUD.data" file. This level of indirection allows the
database layer to move entities around in the file as they grow and
shrink, although it tries to minimize such movement.

Currently, the entire "MUD.index" file is kept in memory. Some portion
of the MUD.data contents is kept in an in-memory cache. Entries in
that cache can also grow/shrink and move around. The cache is "write-back"
in that changes made to cached objects are not written to disk right
away. This reduces the disk I/O tremendously. The MUD server also uses
others kinds and levels of caches to reduce that I/O even more.

So, lets say a player character called "Fred" is logging in to the game.
A connection comes in, containing the string "Fred". The server has a
few pre-defined entities in the database, having fixed keys. One is the
player table, which is a string-keyed hash table, the values of which
are further database keys. This table is stored in the database, like
everything else. The server requests the player table from the database
layer, and gets back a pointer to an in-memory copy of it. The server
looks up "Fred", and gets back a database key to the "player" structure
for player "Fred". That contains the encrypted player password, various
various flags, and various other database keys. These player structures,
like everything else, are scattered all over the database, although each
individual structure is stored as one contiguous entity.

Assume the password is verified, and game-play is to start. One of the
keys in a player structure is the database key of an action (written
in my persisent MUD language) which is to be executed when that player
reconnects to the MUD. The server requests that action from the
action cache, which may in turn have to fetch it from the database
layer, which may in turn have to read it from disk. Eventually, it gets
back a pointer to an in-memory structure describing the action, and
having pointers to one of the two possible executable forms of it (I
originally used a "parse-tree" executable form, and now also have a
somewhat faster byte-code form as well). The server calls the code.

That reconnect code can in turn call on other MUD-language functions and
server builtin functions. This activity can result in messages to the
player, messages to other players nearby, graphics changes to some of
those (my MUD is multimedia), changes to persistent values, etc. The
function eventually terminates, and Fred is fully logged in.

Similarly, there will be a key in Fred's player record that points to
the function to be used to parse and interpret commands coming from
the player. There are other, similar, keys pointing to functions to
handle mouse clicks, numeric keypad typing, etc.

Let's say Fred does something to change his simple string description.
Buried somewhere in the MUD-language code which interprets user commands
will be a simple assignment statement like:

    Me()@p_pDescription := newDescription;

"Me" is a builtin function (implemented directly in the server) that
returns the database key for the active player. The '@' operator means
to select a property in a "thing". The whole of the above means to
assign a new value to that property on that "thing". In my system,
such properties are not fixed, like in a C++ class. So, doing the
above assignment may cause the structure for Fred's "thing" to grow
in size, if it didn't previously have a "p_pDescription" property. The
system takes care of that, and finds a place in the database to store
the string from variable "newDescription". The database key for that is
added to Fred's set of property-value pairs (properties are just database
keys too), via the pointer into the database cache that came from the Me()
key. That database entity is marked as "dirty" because of this, and will
eventually get written to disk by the database code.

One of the keys to all of this is that the interpreter/bytecode-engine
in my system knows implicitly about the database, and how to talk to
it. E.g. The piece of code:

    thingy@EggCount := thingy@EggCount + 1;

translates into bytecode something like:

    pshl    thingy	; access local variable
    pshref  EggCount	; push a fixed 32 bit database key
    pshl    thingy
    pshref  EggCount
    getPrp
    add1
    putPrp

The bytecode machine knows that to execute a 'getPrp' instruction, it
takes a pair of database keys off of the bytecode machine's stack, and
passes them to an internal routine 'getProp'. That routine in turn
retrieves both entities from the database, and looks for the "property"
one in the list of properties on the "thing" one. The resulting value
is then pushed onto the bytecode machine's stack. Similarly, the
'putPrp' instruction passes the top 3 stack elements to 'putProp', which
adds that "property" to the "thing". That may involve a call to database
routine "ioExpand" to expand the space for the "thing", or a call to
"ioDirty" to mark the changed "thing" as needing to be flushed to disk.


Hmm. This didn't come out like I had imagined. Hopefully its useful.
Feel free to ask more questions if you want more details.


To answer some of your specific points:

&gt; -stores things in a database file(s). No more 4000 player files.

Yep.

&gt; -allows me to define objects online. Ie. I can decide I need an object that
&gt; will act like a boat, and I can code and modify this online.

Yep. I have a small program, "MUDCre" that creates a nearly empty database.
*Everything* else is built by sourcing MUD language source files to
create stuff. Note that is likely a very bad idea to do all of your
building online, unless you have a very good way of dumping that back
out in a form that you can then feed back in. For some of the trickier
stuff, it is easier to look at things in a nice editor, and to be able
to use the edit/compile/debug cycle, than to try to get it all correct
online.

&gt; -doesn't have every object in memory, only when needed, otherwise on file.

Yep.

&gt; -doesn't require me to learn it's "own custom embedded language", this one
&gt; really gets to me

Sorry, but I have a custom language. I view this as a good thing. Sure,
it takes a bit of time to implement, but its a fun thing to do (well, it
is for programming-language geeks like me). The custom language is also
likely to be much more appropriate for writing MUD scenarios that some
randomly chosen language. In particular, it won't have nasty things like
uncontrolled ways to issue system commands, write to disk files, etc.!

&gt; -somehow allows for security and access levels while coding

Yes. See my online docs.

&gt; -somehow allows for an event type system

No really a separate system. See my 'After' builtin routine, and how
handler actions are attached to player and non-player characters.

&gt; -allows code to be contained in packages and has appropriate management
&gt; features. Ie. I can write the code offline in a file and then upload the
&gt; file to the server

Yes, except that I use the concept of "symbol tables" to encapsulate
things. I find it works quite readily, and by hiding symbols in private
tables, only the owner of those symbols even knows they exist.

&gt; -will allow for http access to the database

Nope. I have no idea what this would mean, in general.

-- 
Don't design inefficiency in - it'll happen in the implementation.

Chris Gray     cg#ami-cg,GraySage.Edmonton.AB.CA
               <A  HREF="http://www.GraySage.Edmonton.AB.CA/cg/">http://www.GraySage.Edmonton.AB.CA/cg/</A>



_______________________________________________
MUD-Dev maillist  -  MUD-Dev#kanga,nu
<A  HREF="http://www.kanga.nu/lists/listinfo/mud-dev">http://www.kanga.nu/lists/listinfo/mud-dev</A>

</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<!--X-Follow-Ups-End-->
<!--X-References-->
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00792.html">Re: [MUD-Dev] Embedded languages, object persistance... ack.</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00794.html">RE: [MUD-Dev] Admins as Mortals twist</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00839.html">Re: [MUD-Dev] Embedded languages, object persistance... ack.</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00782.html">Re: [MUD-Dev] Two threads forced to one CPU? (was: Collecting ideas for a MUD server...)</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00793"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00793"><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>Re: [MUD-Dev] Embedded languages, object persistance... ack.</STRONG>, <EM>(continued)</EM>
<ul compact>
<LI><strong><A NAME="00792" HREF="msg00792.html">Re: [MUD-Dev] Embedded languages, object persistance... ack.</A></strong>, 
Laurent Bossavit <a href="mailto:bossavit@cybercable.fr">bossavit@cybercable.fr</a>, Wed 29 Dec 1999, 22:40 GMT
</LI>
<LI><strong><A NAME="00800" HREF="msg00800.html">Re: [MUD-Dev] Embedded languages, object persistance... ack.</A></strong>, 
J C Lawrence <a href="mailto:claw@kanga.nu">claw@kanga.nu</a>, Sat 01 Jan 2000, 19:03 GMT
<UL>
<LI><strong><A NAME="00842" HREF="msg00842.html">Re: [MUD-Dev] Embedded languages, object persistance... ack.</A></strong>, 
Jay Carlson <a href="mailto:nop@mitre.org">nop@mitre.org</a>, Tue 04 Jan 2000, 01:28 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00839" HREF="msg00839.html">Re: [MUD-Dev] Embedded languages, object persistance... ack.</A></strong>, 
Jay Carlson <a href="mailto:nop@mitre.org">nop@mitre.org</a>, Mon 03 Jan 2000, 20:25 GMT
</LI>
<LI><strong><A NAME="00793" HREF="msg00793.html">Re: [MUD-Dev] Embedded languages, object persistance... ack.</A></strong>, 
cg <a href="mailto:cg@ami-cg.GraySage.Edmonton.AB.CA">cg@ami-cg.GraySage.Edmonton.AB.CA</a>, Thu 30 Dec 1999, 05:09 GMT
</LI>
</ul>
</LI>
<LI><strong><A NAME="00782" HREF="msg00782.html">Re: [MUD-Dev] Two threads forced to one CPU? (was: Collecting ideas for a MUD server...)</A></strong>, 
cg <a href="mailto:cg@ami-cg.GraySage.Edmonton.AB.CA">cg@ami-cg.GraySage.Edmonton.AB.CA</a>, Fri 24 Dec 1999, 19:03 GMT
<UL>
<LI><strong><A NAME="00787" HREF="msg00787.html">Re: [MUD-Dev] Two threads forced to one CPU? (was: Collecting ideas for a MUD server...)</A></strong>, 
Hans-Henrik Staerfeldt <a href="mailto:hhs@cbs.dtu.dk">hhs@cbs.dtu.dk</a>, Tue 28 Dec 1999, 16:05 GMT
</LI>
</UL>
<UL>
<li>&lt;Possible follow-up(s)&gt;<br>
<LI><strong><A NAME="00788" HREF="msg00788.html">Re: [MUD-Dev] Two threads forced to one CPU? (was: Collecting ideas for a MUD server...)</A></strong>, 
cg <a href="mailto:cg@ami-cg.GraySage.Edmonton.AB.CA">cg@ami-cg.GraySage.Edmonton.AB.CA</a>, Tue 28 Dec 1999, 17:44 GMT
<UL>
<LI><strong><A NAME="00789" HREF="msg00789.html">Re: [MUD-Dev] Two threads forced to one CPU? (was: Collecting ideas for a MUD server...)</A></strong>, 
Greg Miller <a href="mailto:gmiller@classic-games.com">gmiller@classic-games.com</a>, Wed 29 Dec 1999, 17:00 GMT
</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>