0

So, I just realized that Java has a built in API system that works with JavaScript and apparently other scripting languages that are JSR-223 compliant. Now, I'm designing a game engine and I'm wondering if I should just use the integrated JavaScript support or figure out how to use Lua.

QUESTION: Can the Java Scripting API easily support Lua? If so, how?

If you feel like it: Would it be unknown to do the scripting side of a game engine in JavaScript?

EDIT: I need scripting capabilities for my engine to allow the creation of AIs, special voxels (Like blocks in minecraft) and other add-ons to the game. I'm not set on doing all this creation in a scripting language because the difficulty of doing so but a scripting language appears as a good alternative to making JARs for all game content. I'm simply exploring what I can do with Java.

2
  • You should list what your project requirements are otherwise this will be too opinion-based. Commented Sep 10, 2013 at 3:09
  • I hope my edit helps. Commented Sep 10, 2013 at 10:58

2 Answers 2

1

The Java Scripting framework relies on the code implementing JSR-223 being written in Java. As such lua won't work.

However, you can use an implementation of lua written in Java such as luaj which has JSR-223 support included.

Note: luaj is not a complete clone of lua but it's pretty functional and allows you access to java classes etc.

On the subject of choosing a scripting language, as you are using Java as your system programming language, some of the benefits of using lua as a scripting language don't apply e.g. fast, small footprint, excellent C integration.

So really it becomes a personal preference. Javascript would be probably be fine, as would Jypthon, JRuby or luaj.

0

It is not a wise idea to make a game engine in JS. Despite possible(see Node.js / Three.js), JS is rather slow because is interpreted. Node.js has JIT compilation, but it's still 3-4x(best case) slower than C++ equivalent.

I never used Lua or Java Scripting API, I cannot give you an answer on this, but I think the speed of JS will change your mind.

1
  • I'm not making the game engine in JavaScript. I am making my engine in Java and thinking about using JavaScript for all the scripting in the game. Commented Sep 10, 2013 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.