Erlang hints for an OO junkie?

Johan Warlander johan@REDACTED
Mon Aug 9 16:24:11 CEST 2004


Hi,

I've been experimenting with Erlang for a bit and I've found it to be a very
interesting language, with nice features. However, being relatively new to
functional programming in general and Erlang in particular, I have a question
which might have a semi-obvious answer that I'm just not aware of:

If I were to implement a text-based online game where I would like to model a
game world of physical objects ranging from living things like animals,
monsters and humans  through inanimate things like swords, backpacks and
apples.. what would be the most Erlang-esque way to go about it?

>From the perspective of an OO programmer, in another language my choice
would've been a hierarchy of classes somewhat like the following:

ANIMAL <- LIVING <- OBJECT
BACKPACK <- CONTAINER <- OBJECT
SWORD <- WEAPON <- (OBJECT, DAMAGE_SOURCE)
ARMOR <- WEAPON <- (OBJECT, DAMAGE_SINK)

The examples I've seen so far of Erlang programs, and the relatively short
time I've had to study the language, hasn't given me any clear indications as
yet of how to go from this model to something more appropriate for the way
Erlang works. Obviously, this is a good indication I shouldn't be starting any
big projects just yet.. ;) Still, it would be nice if anyone has some good
pointers to get me started, and help me "shift" out of the OO paradigm for the
task at hand.

Regards,
Johan Wärlander




More information about the erlang-questions mailing list