For instance, if I wanted to make a game which used a Python main file, but have another file with Ruby methods on it, how would I call those methods individually?
Secondly, how could I make a Ruby gem/library with python code in it? I can't find a way other than exec("python file.py")
which is not a gem, requires the shell to be active, and have Python installed, so that wouldn't be as reliable as I'd want it to.
-
1A quick search turns up some suggestions, e.g. stackoverflow.com/questions/3679501/calling-python-from-ruby . But it's probably faster, easier, and more robust to simply rewrite all your code in a single language.amon– amon2017年07月20日 21:30:54 +00:00Commented Jul 20, 2017 at 21:30
1 Answer 1
If you want to do a game, create it in a single language. As it stands, games are already pretty taxing programs. Even looking at a games basic structure, you have a main loop that is executing consistently, while updating absolutely everything within the games world.
Now while it would be an interesting idea to combine two languages, think of what that would do to performance. You would have to call another program from within the game to execute that code, which takes up extra time, which could frustrate players if its noticeable (and i have a feeling it would be).
I'd honestly say go with just python or just ruby. However, maybe later on down the line, if you build your own engine from scratch, you could implement a Ruby-like scripting language (though that could be a whole other thing and topic of discussion in itself).