Exploring a 23 years old code base: LambdaMoo MUD Part 2

In this second article I will continue my jorney on LambdaMoo code base.
The C code is very well written.
Sometimes the API abuse global variable to avoid passing around identifier like output database file descriptor or the like.

Because a lot of the system has been written in the Moo language, the core is composed of:

  1. an object system
  2. an interpreter
  3. a scheduler
  4. the server infrastructure.

The scheduler resemble a small round robin Operating System scheduler.
The server infrastructure is a generic single thread-multi process system.
The main loop is crystal clear on this respect.

A big part of the code is about list management and parser. Also some hash function are implemented from ground up.

After implementing a small procedure to dump the database on a sqlite3 file, I realized it will be useless. The entire system has a well written API, but object are supposed in memory, so when the API return an object, the code change it by simple assignment (!)

Anyway, it was very easy to link sqlite3 to the code, because sqlite3 is a C-pure code and can be linked as a single file (“amalgamation”).

So LambdaMoo is a small VM with a Smalltalk-like in memory image, and a basic object oriented hierarchical system.

 

Lua is another C-based language which could be used as a replacement for the standard language.

 

Lesson Learned

Sqlite3 and Lua are very easy to embed on legacy C code, and their dependency are minimal. You can “drop in” a very small set of files and integrate them; also being C-pure is another advantage.
 
LambdaMoo is a beautiful example of an extensible framework on which the building pieces are built in itself and on an easy-to-understand in memory database.
It is fascinating the way the “multiplexer” is used: to communicate with the clients, and also for internal task scheduling (somewhat).
The simplicity you can understand the system is another lesson you must learn if you want to do real big software!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.