Java game engine, writing own scripting language

javascripting

I'm planning to create a simple Visual Novel game engine out of Java. I've developed for Java before but I have experience with other languages. What I would like to do, is to create my own scripting language that people can use with the engine to make the complete game out of a script, since Visual Novels are simple enough to do it, I think.

What I don't know is, is Java suitable for making such a scripting language? The way I imagine it is, the engine reads a script file in the game folder, and takes in the input and executes each command linking up to a certain function or something like that. I'm not sure how difficult theoretically that would be to pull off.

As you can probably tell I'm a newbie when it comes to this.
Thanks.

Best Answer

It sounds like you need a domain-specific-language (DSL). Here's an article on DSLs within Java

DSLs are small, expressive programming languages custom designed for specific tasks. In this four-part series, Venkat Subramaniam introduces the concept of DSLs and eventually shows you how to build them using Java

and there's a related question on SO.

You can use Scala to write DSLs and run them on the JVM. However I would warn you that without Scala knowledge it's a (IMO) non-trivial task to do this.

Alternatively you can use a Java implementation of a scripting language together with the Java Scripting API. This will allow you to use an existing language and have it compiled into bytecode. The advantag eis that you're using an existing language. The disadvantage is that it's not specific to your particular needs.

Related Topic