-2

Or is the script generally converted to a known language such as C++ first?

And how generally to you integrate a scripting language with the say a game engine?

2
  • Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see How to Ask
    – gnat
    CommentedAug 18, 2014 at 0:42
  • let's be clear: compile means to translate a program from a language into another. The alternative is to interpret a program, which means executing it instruction by instruction. Compiling allow for better performance, but interpreting do not require pre-processing (i.e., starting faster). Many game scripting languages are merely interpreted (e.g. bash) because performance isn't so important in their domain
    – pqnet
    CommentedAug 18, 2014 at 5:08

2 Answers 2

6

It varies by language. Many scripting languages are run on VMs that are coded in assembly or C. Python and Ruby are both examples of this. The second part of your question is far too broad so I'm going to narrow it down and talk about Lua for a bit.

Lua is an excellent case study for anyone wanting to understand or build a scripting language. It very much follows the philosophy of "Be fast, be light, and stay out of the way". It can be used with its own VM or in a number of other contexts such as compiled directly to C. This makes it a very popular choice for both game scripting as well as for embedded systems programming since it has a tiny memory footprint for a dynamically typed scripting language. Lua can have objects if you want or not if you don't.

Lua has a C API, this is how you bolt Lua on to your C based engine (or C++ if you'd like) In general, you use what are called foreign function interfaces (FFI) to do things like this in other languages.

Our game development site goes into massive detail on this process as well as specifics for Lua.

    -1

    A scripting language like any computer language has to convert its commands to machine code in order to execute. Given this fact you can take various paths to accomplish the task. You can convert the code into another language, or directly to machine code or to some custom "machine code" that runs on a VM. All the solutions have their pros and cons so the solution you choose depends on the nature of your problems. Integrating a scripting language with a game engine should not be that hard. All the game engines provide programming interfaces to integrate them with your code part of which is the scripting language.

    3
    • 1
      No, interpreters do not convert the script code to machine code. They are interpreting some representation derived from the source code (i.e. processing that representation repeatedly), often AST or sometimes bytecodeCommentedAug 18, 2014 at 6:06
    • They interpret user code into what?
      – Gus
      CommentedAug 18, 2014 at 6:12
    • 1
      Read the interpreter wikipage.CommentedAug 18, 2014 at 6:19

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.