Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question

closed as too broad by MichaelT, Doc Brown, BЈовић, jwenting, gnat Aug 18 '14 at 10:47

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs. If this question can be reworded to fit the rules in the help center, please edit the question.

    
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 Aug 18 '14 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 Aug 18 '14 at 5:08

2 Answers 2

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.

share|improve this answer

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.

share|improve this answer
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 bytecode –  Basile Starynkevitch Aug 18 '14 at 6:06
    
They interpret user code into what? –  Gus Aug 18 '14 at 6:12
1  
Read the interpreter wikipage. –  Basile Starynkevitch Aug 18 '14 at 6:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.