Why you would want to call scripts...

Started by
3 comments, last by Kylotan 17 years, 1 month ago
I recently learned on how to make Python calls from C++. I think it's really, really cool that you can do that, but when would you ever want to? The only scenario I can think of you would ever want to call Python from C++ is when it's just plain easier to write scripting code rather than writing lower level code, but isn't that the case with all scripting languages? Can someone enlighten me of when you would ever want to call Python from C++ besides that it's just plain easier to write Python code.
Advertisement
By using scripts to drive your engine, you don't have to recompile your whole application in case you want to modify some of it's behaviors later on.

As an additional benefit, if you expose the scripting interfaces to the end users, they can make mods for your application. If you have a good game engine, for example, this may be a strong selling point.

Niko Suni

First, it's usually easier to concentrate on game details in a high-level programming language, and it's more expressive as well. But that's the "it's easier" argument.

Second, you don't need to recompile the game when you want to alter something. You can run the game in full optimization mode and change scripts on the run in the course of a few seconds, as opposed to the half-hour-plus compile and link times on large projects. Sometimes, some virtual machines even allow you to pause the game, tweak a few values, call one or two python functions manually, and resume with the new state.

Third, it's difficult to get something wrong done in the sandboxed environment of a script. So, you can allow people to write scripts and distribute them very easily (even let the game download them automatically) without putting the user's computer's safety at risk.
Ah, I see now.

Thanks for the replies.
Quote:Original post by Drunken_Monkey
Can someone enlighten me of when you would ever want to call Python from C++ besides that it's just plain easier to write Python code.


Don't you think that's a great reason all on its own? If you can make coding a game twice as quick or easy, then why not do it?

This topic is closed to new replies.

Advertisement