Scripting in Java [closed]
Me and some friends are writing a MORPG in Java, and we would like to use a scripting language to, eg. to create quests.
What scripting language should we use? What scripting language should we not use?
Asked by: Brad318 | Posted: 28-01-2022
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.
javax.script package), Groovy and JRuby are also worth looking at too.
By the way, you should look at Wyvern, also an MMORPG written in Java and using Jython for scripting. Steve Yegge, its author, has much to say about it from time to time. :-)Answered by: Arnold105 | Posted: 01-03-2022
Java supports a variety of (scripting) languages, some are listed in Wikipedia here and here. You probably should choose language with powerful DSL and metaprogramming capabilities, such as Clojure.
How about Jython?
what about creating your own specialized scripting language? If your app is written with java, you can use ANTLR (http://www.antlr.org/) to create your language parsing code.
The reason I say this is because a general purpose scripting language may provide too much power (because the script it to be used for quests only i assume).
But if making your own language is too hard then any of the above suggestions works - you just have to figure out how to bind the game's runtime into the script. I also suggest Lua (http://www.lua.org/) as another choice that lots of games use.Answered by: Aida642 | Posted: 01-03-2022
Donâ€™t use a scripting language! Instead focus on configurability (which is something that a non-programmer can do well).
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?Answered by: Maria738 | Posted: 01-03-2022
See Java: Scripting language (macro) to embed into a Java desktop applicationAnswered by: Catherine510 | Posted: 01-03-2022
You have quite a few options:
- Groovy - http://groovy.codehaus.org/
- Jython - http://www.jython.org/Project/
- JRuby - http://jruby.codehaus.org/
Possibly even BeanShell (http://www.beanshell.org/)
I'm a fan of Python myself so I'd recommend Jython, but they're probably all reasonable options.Answered by: Maya574 | Posted: 01-03-2022
LuaJ seems to be a nice way to embed Lua into Java:
http://sourceforge.net/projects/luaj/Answered by: Arnold268 | Posted: 01-03-2022
I am a big fan of Python/Jython due to the clean syntax - which may suit you if you have some python experience.
Otherwise Groovy which is based on Java syntax and may be an easier learning curve if most of your developers are Java guys. It also has the advantage of closer ties with the Java language and libraries.
Beanshell is good if you have simple scripting in mind - it doesn't support classes. However I don't think it has had any support over the last few years (the JSR seemed to kill it off...) so is perhaps a bad choice if support is important to you.Answered by: Elise138 | Posted: 01-03-2022
scripting - JRuby and Java objects
Please tell me if it is possible to do the following: create an instance of a specific class in Java pass it to JRuby to do something with it continue using the "modified" version in Java May you provide a small working example? EDIT: It turns out that embedding was the simplest way to achieve this. More information is available on
Security with Java Scripting (JRuby, Jython, Groovy, BeanShell, etc)
I'm looking to run some un-verified scripts (written in a yet-to-be-determined language, but needs to be Java-based, so JRuby, Groovy, Jython, BeanShell, etc are all candidates). I want these scripts to be able to do some things and restricted from doing other things. Normally, I'd just go use Java's SecurityManager and be done with it. That's pretty simple and lets me restrict file and network access, the ability ...
java - Bean Scripting Framework
scripting - JSR223: Calling Java "varargs" methods from script
api - Java + Scripting languages (JSR 223)
Scripting (with PHP) in Java?
I'm trying to write a simple Java game. I have a NPC class, with a function Dialog which returns what the npc would say, which would depend on various conditions. I'm thinking that it would probably make sense to offload the logic of deciding what each npc would say to a scripting language, so that it could be changed updated easily. That way, I can create each NPC instance using something like npc Mayor = ...
Closed. This question needs to be more focused. It ...
java - Measure code coverage for remote scripting tests
Closed. This question does not meet Stack Overflow guid...
java - How to justify using a scripting language as part of a project
I have a specific project in which I want to use either a scripting language + C, or as an alternative a 100% Java solution. The program adapts a legacy system for use with other moderns systems. Basically, I have few choices as to what language I can use. I have C/C++, Java 1.4, and I have also compiled the Lua for this environment. The program does 'screen scraping' and has to deal with alot of s...
Is there a Java Scripting Language that Can Work Without Caching? Jython? Groovy? etc?
We have an existing java-based heavyweight project that needed an interactive script interpreter. After a fair amount of research we eventually ended up with Jython, one of the reasons being that the customer's group already has a large amount of python expertise, and it's an easier sell to give them an api in a language close to one they already know. Alright, well at first this was fine, but there turn...
Still can't find your answer? Check out these amazing Java communities for help...
Java Reddit Community | Java Help Reddit Community | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)