# Ruby for MMORPG Scripting

**URL:** <https://www.ruby-forum.com/t/ruby-for-mmorpg-scripting/108845>\
**Category:** Ruby\
**Created:** [July 8, 2007, 2:16am UTC](https://www.ruby-forum.com/t/ruby-for-mmorpg-scripting/108845 "2007-07-08T02:16:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TongKe\_Xue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8dc957/32.png) [@TongKe\_Xue](https://www.ruby-forum.com/u/TongKe_Xue)\
**Post date:** [July 8, 2007, 2:16am UTC](https://www.ruby-forum.com/t/ruby-for-mmorpg-scripting/108845/1 "2007-07-08T02:16:45Z")

</div>

Hey Everyone,

I’m working on a massive simulation project (like worldforge). I need  
to  
be able to allow users to script objects in the world. I am thinking of  
ussing Ruby as my scripting language of choice. However:

(1) I need to be able to limit the memory usage of the object.  
(2) I need to be able to limit the CPU cycle usage of the object.

I.e. I don’t want users to use my game to calculate digits of PI.

Is there a way (or an existing implemntation of Ruby) to let me  
create  
these light-weight tasklets/threadlets/processlets (there’s too many  
objects to have a UNIX process for each object) such that I can limit  
the  
memory/cpu usage on each?

Thanks,  
–TongKe  
(When replying, please do reply all as I might unsubscribe due to the  
traffic.)

---

<div class="post-metadata">

**Author:** ![TongKe\_Xue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8dc957/32.png) [@TongKe\_Xue](https://www.ruby-forum.com/u/TongKe_Xue)\
**Post date:** [July 8, 2007, 2:25am UTC](https://www.ruby-forum.com/t/ruby-for-mmorpg-scripting/108845/2 "2007-07-08T02:25:46Z")

</div>

On 7/7/07, TongKe Xue [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I.e. I don’t want users to use my game to calculate digits of PI.
> 
> Is there a way (or an existing implemntation of Ruby) to let me create  
> these light-weight tasklets/threadlets/processlets (there’s too many  
> objects to have a UNIX process for each object) such that I can limit the  
> memory/cpu usage on each?

Not really as far as I know. You can try using Timeout to limit the  
amount  
of time a given task runs, but that is certainly not infalliable. Short  
of  
creating your own ruby impl. / heavily modifying another ruby impl. the  
only  
way I could think to do this would be to make each a process and use the  
OS  
facilities (which you said you didn’t want to use). Unless maybe java  
has  
per thread cpu / memory limits, in which case you might get jruby to do  
what  
you want.

Thanks,

---

<div class="post-metadata">

**Author:** ![TongKe\_Xue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8dc957/32.png) [@TongKe\_Xue](https://www.ruby-forum.com/u/TongKe_Xue)\
**Post date:** [July 8, 2007, 11:49am UTC](https://www.ruby-forum.com/t/ruby-for-mmorpg-scripting/108845/3 "2007-07-08T11:49:14Z")

</div>

I don’t think you’d want to use Ruby for MMORPG scripting.

Current implementations are too resource heavy for that.

Try a Scheme, a Forth, a Smalltalk or Lua.

This comes from a huge Ruby fan. This is one of the ONLY things I  
wouldn’t use Ruby for.

On second thought, there’s a project to compile Ruby to Smalltalk.  
Maybe a mod of that would give you what you want.

Aur

---

<div class="post-metadata">

**Author:** ![TongKe\_Xue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8dc957/32.png) [@TongKe\_Xue](https://www.ruby-forum.com/u/TongKe_Xue)\
**Post date:** [July 8, 2007, 9:31pm UTC](https://www.ruby-forum.com/t/ruby-for-mmorpg-scripting/108845/4 "2007-07-08T21:31:49Z")

</div>

You’d have to do the same thing that users of the other script languages  
do, they only perform limited computation and if their computation is  
incomplete, they yield and pick up later. The real issue becomes a  
matter of how light weight are ruby threads/objects and exactly how many  
do you expect to be running at once.

Also, the JRuby and IronRuby stuff looks promising at increasing the  
speed of ruby drastically.

TongKe Xue wrote:

> Hey Everyone,
> 
> I’m working on a massive simulation project (like worldforge). I need  
> to  
> be able to allow users to script objects in the world. I am thinking of  
> ussing Ruby as my scripting language of choice. However:
> 
> (1) I need to be able to limit the memory usage of the object.  
> (2) I need to be able to limit the CPU cycle usage of the object.
> 
> I.e. I don’t want users to use my game to calculate digits of PI.
> 
> Is there a way (or an existing implemntation of Ruby) to let me  
> create  
> these light-weight tasklets/threadlets/processlets (there’s too many  
> objects to have a UNIX process for each object) such that I can limit  
> the  
> memory/cpu usage on each?
> 
> Thanks,  
> –TongKe  
> (When replying, please do reply all as I might unsubscribe due to the  
> traffic.)

---

<div class="post-metadata">

**Author:** ![TongKe\_Xue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8dc957/32.png) [@TongKe\_Xue](https://www.ruby-forum.com/u/TongKe_Xue)\
**Post date:** [July 8, 2007, 7:50pm UTC](https://www.ruby-forum.com/t/ruby-for-mmorpg-scripting/108845/5 "2007-07-08T19:50:44Z")

</div>

SonOfLilit wrote:

> Maybe a mod of that would give you what you want.  
> Actually, given that C, Scheme and Forth are good candidates, this might  
> also be a good Erlang application. I don’t know enough about Lua to  
> comment about it, but it’s _very_ popular in game circles, and it’s  
> quite “C-friendly”.

Yeah. Smalltalk would probably work. So would Java, for that matter. I  
personally wouldn’t learn another language if I wanted to build an  
MMORPG, though, since I’m a better Forth programmer than I am a C  
programmer anyhow. 😉

I still wonder why the OP wants to build an MMORPG from scratch, though,  
given the number of existing open source projects that could be  
hacked/forked/whatever. “worldforge” is itself open source, IIRC. 🙂
