Reasons for using a scripting language in your game?

Whats the point of having a scripting language in Java? Why can’t you just program everything in Java? What the point of putting it in a different language?

Java already is bytecode, so having one kind of bytecode being interpreted by another kind of bytecode is quite redundant.
Scripting is really only useful in compiled languages where recompiling the entire game for one small change is a waste of time.

Also, the awfulness of C++ probably contributes to people wanting to use another language as much as possible without sacrificing performance.

It makes your game easier to mod because your users won’t have to compile java code and get the clsspath to the game’s libraries right, they can just edit the script files.

I also remember seeing somewhere that it’s easier to secure than classes loaded by reflection

Wouldn’t the script’s interpretation take time too? I mean it’s kinda a big overhead for a possible convenience factor…

Why do this with Java? Java has a archive loader to make ‘plugin’ development really easy, and you get to have a TON more access than you could with any scripting language. Plus, no interpretation time.

Also, there’s some really good answers here: http://stackoverflow.com/questions/22219768/why-use-scripting-languages

You are half right. In the case of Java, JVM has to load the bytecode of the classes and interpret them. There is already one interpretation being done, then interpreting another scripting language will be an overhead, and is not recommended.

In the case of C++, there is no VM lying around, the code is completely compiled to native platform code, and is loaded in the runtime by the operating system’s loader, so having an interpreting script language won’t be much of the overhead when compared to Java. This is what Heroes meant in his comment.

However, I don’t think so, with the JIT, Java in the recent years is much more faster, and sometimes, due to optimisations, can outperform C++ (citation needed), so I don’t think performance or speed consideration is needed now-a-days.

When I said waste of time I was referring to compilation time.

Big games can take a long time to compile (or rather, optimise. It’s the optimisation passes that take the longest time. Most of the compilation process is rather quick). No point in recompiling for each little change when you could just edit a text file and retry instantly.

Java isn’t optimised at compile time, and so compile speeds are usually fine. Therefore scripting is just a new layer of indirection that isn’t really needed.

@SHC: Java will very rarely be able to beat adequately written C++, but it gets close enough that they can usually be classed as the same speed. Really well-written C++ will practically always beat Java.

Hi

I have frequently succeeded in writing Java code that beats a bit (about 5 to 15%) moderately well written C++ code since 2006 and this is what refrained me from going back to C and C++ at the beginning. Even my most simple blueprints with JOGL and AWT were faster than their equivalents in C++ with GLUT and SHC seems to forget that Java (OpenJDK and Oracle Java, except maybe OpenJDK Zero) isn’t purely interpreted except when you use -Xlint.

“bigger” studios use scripting to allow “designers” contribute “code” without the requirement of c/c++/java knowledge … in a “sandboxed” environment.

live-coding is not the biggest advantage since you should not put “expensive” or time-critical code into the script interpreter. yet, one typical application for small dev teams is a scripted finite state machine to handle dialog-trees … or similar. better put the effort into a shader-live-coding system, which is technically the same.

if you worry about compile duration, get jrebel or learn to code with the JVM buildin hot-swap. o/

There are no sound technical reasons to use scripting languages with Java to make games. Scripting solved a problem that C++ has that Java does not have.

Cas :slight_smile:

To be honest , the way computers are heading is most likely going to mean that future programmers will sort of shrug off on performance just simply to how annoying it is to optimize and how little they would gain from it. But for now scripting is useful , a lot of the previous comments are correct , great for people trying to mod your game , great for loading in external data so that you dont have to right yet another god damn tile class or for things like file handling , python file handling vs java filehandling is a bit step and being able to just call a save script instead of writing out a save class is better. Scripts wouldnt really be performance useful when in a consistent method so you obviously wouldnt use it to handle your tick function. They have their advantages and it;s really a situational thing.

A scripting language should make something easier. AIs and behaviors are classic examples and being usable by non-programmers.

As yet I’ve not noticed any scripting languages that are actually easier than Java in any particular way. I notice wryly that Unity uses C# as its core “scripting” language as it is. That should give people some clues :slight_smile:

Cas :slight_smile:

Example: directly coding a behavior tree in a java or c++, etc. like language would blow chunks.

Actual game development is coming totally different direction that your vision suggest. Currenty hype is to get away of redudant overhead(Mantle, metal, dx12, GL next, Data oriented design, more c:ish c++ coding, simd, multithreading, etc). All these need more attention of programmers not less. These all also give you substantial speed gains. Single core performance does not increase fast anymore. You need serious effort to compete. Just look where Unreal engine is heading, hot loadable c++ instead of scripting language.