Sign in to follow this  
Drunken_Monkey

Why you would want to call scripts...

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this