Scripting in Java [closed]

By : eflles
Source: Stackoverflow.com
Question!

Me and some friends are writing a MORPG in Java, and we would like to use a scripting language to, eg. to create quests.

We have non experience with scripting in Java. We have used Python, but we are very inexperienced with it. One of us also have used Javascript.

What scripting language should we use? What scripting language should we not use?

By : eflles


Answers

LuaJ seems to be a nice way to embed Lua into Java:

http://sourceforge.net/projects/luaj/



Short version

Don’t use a scripting language! Instead focus on configurability (which is something that a non-programmer can do well).

Longer version

One oft-used argument in favour of having a scripting language is that it allows for lesser programmers to more trivial tasks. Don't belive this, it will not save you any time, since trivial tasks are already accomplished by real programmers in no time. Aim for configurability instead of scripting, and you will have a much lower risk of bleeding over complex algorithms and concepts into the incapable hands of game designers. :)

Lack of hotswapping (edit-and-continue) would have been a reason to implement a scripting language in an MMOG (you don’t want to reload the whole game for a minor code change), but using Java, with built-in hotswap, you really have no reason for adding a scripting language on top.

I have spent years pondering these questions; in the day I implemented a complete scripting language, IDE, VM, debugger, etc for an MMOG myself. Since, I have grown wiser.

If you still choose to go down the infinitely crappy path of no return, keep the following in mind.

  • Pick a mature language which has been around for a while.
  • Auto testing, debugging and editing will suck bigtime until you make your own tools/plugins/start hacking around in the VM.

To date, I have never seen a DSL that improved the situation (getting a more maintainable product). Myself, I integrated Python into my indie game engine, but eventually came to my senses and ripped it out. "Stackless Python" is just a way of saying "unmaintainable but fast". Please, anyone correct me if I'm wrong?



I'm responsible for a fairly large hybrid Java/Jython system. We use java for core API development, then wire Java objects together using Jython. This is in a scientific computing environment where we need to be able to put together ad-hoc data analysis scripts quickly.

If I were starting this system from scratch today, I would not choose Jython as the scripting language. I like Python fine, but I frequently encounter awkward mismatches between the Python type system and the Java type system. For example, if you just want a hashtable, should you use a Python dictionary or a Java HashMap? The decision might be different depending on whether you are just using the data structure locally in Python code or passing it across the Java boundary. Jython does a certain amount of type coercion for you, but it's not perfect. It's annoying to even have to think about issues like this when the purpose of using a scripting language in the first place is to enhance your productivity.

I assume JavaScript or JRuby would have similar issues. Today I would choose a scripting language that is specifically targeted to the JVM and leverages the Java type system. The obvious candidates are Groovy and Beanshell; Groovy seems to have been picking up momentum lately so I'd look most closely at it.

By : thork


This video can help you solving your question :)
By: admin