Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scripting language

Status
Not open for further replies.

jstreich

Programmer
Apr 20, 2002
1,067
US
I'm working on a graphical MUD, and I'm thinking about making a scripting (or other meta-) language that will allow a super user/world builder to create a script to attach to an item. When a user uses the item the script is "run".

I think I know how I'm going "run them" and I have an idea about what the language looks like, but I'm having trouble figguring out how to parse the language fast and effeciently. I'm thinking I can parse the language into an array of "actions" when the script is added/loaded -- and then when the action occurs, perform it. This means that the JVM will have a bunch of loaded scripts ready to run, even if they aren't used (or used once) and then I'm using a lot memory needlessly -- but if I reread/parse the script when actions happen, then I am taking too much CPU time when an action is performed.

[plug=shameless]
[/plug]
 
I would certainly preload the scripts/actions - memory is cheap and and doubt these scripts would take up much memory - but speed in these things is everything, and I would rather sacrifice memory over speed :)

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
... or you could write a 'script cache' so that often used scripts are more readily available.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
I would certainly preload the scripts/actions - memory is cheap and and doubt these scripts would take up much memory - but speed in these things is everything, and I would rather sacrifice memory over speed :)
Memory might be cheap, but I don't have a dedicated server for it (yet)...

... or you could write a 'script cache' so that often used scripts are more readily available.

Tim
That's not a bad idea, but memory managment is still in the hands of the JVM, so releasing a script to load another won't free the memory when I "release" it -- but when the GC runs.

[plug=shameless]
[/plug]
 
releasing a script to load another won't free the memory when I "release" it -- but when the GC runs

Well yes, but it does get released at some point, and sooner under heavier memory loads.

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Well yes, but it does get released at some point, and sooner under heavier memory loads.

Tim
What I fear this scenario:
1. Cache is full and has script A as the least recently used in cache.
2. User uses item with script X in it.
3. X is loaded into the cache, A is released
4. Another user uses an item with script A attached,
B is released and A is loaded into it's spot.

At the end, I have 2 copies of A in memory, one without a handle to it -- waiting to be GC'd. I realize that with a cache bad timing will always happen every now and again, but with garbage collection, it'd be a very bad thing to have happen. Not to mention memory and CPU the caching would take up... Perhaps there is a way to make each script take up a smaller amount of memory?

[plug=shameless]
[/plug]
 
Fast CPUs are cheap to.

Rule 2 of Optimization is:
First program according to the KISS principal: Keep it simple, stupid.
Then test and measure.
Never believe your assumptions.
In most circumstances performance-tuning isn't necessary.
It's wasted development-time and introducing new bugs.

seeking a job as java-programmer in Berlin:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top