Sign in to follow this  

Combining a Language With a Language

This topic is 4379 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This question stems from many others on these forums about programming languages, which normally seemed to get answered with "Well, C/C++ is better for your engines, and use a higher level language for game logic." Let me start off with an example. Let's say I was making a MUD. I wanted to do the networking core in C/C++, and any other low level routines needed, then do the game world in a language such as Python. How exactly might this work? Do I load a compiled C/C++ DLL within my Python code? Or do I build an interpreter into my engine. Sorry for my ignorance on this subject, but I'm not too keen with Python yet, or any other higher level programming language for that matter. I don't want to isolate this to just Python either. Would the same procedure for using Python to do game logic on top of a C/C++ core be used for Lua? Scheme? Lisp? Ocaml? Among many others I'm missing? I'm looking into many different high level languages, just need some help on how to go about doing something like this. =) Thanks!, -Dave

Share this post


Link to post
Share on other sites
Quote:
Original post by dmreichard
Do I load a compiled C/C++ DLL within my Python code? Or do I build an interpreter into my engine.


You can do it both ways. Extending python (having a Python program call C++ code) is somewhat easier than embedding python (adding a Python interpreter to a C++ program), since any useful embedding will require extending anyway (so the embedded Python interpreter interact with the C++ code).

Quote:
I don't want to isolate this to just Python either. Would the same procedure for using Python to do game logic on top of a C/C++ core be used for Lua?


To a large extent, I would expect it to be so, yes. For some other languages, you may in fact just end up with DLLs -- just not DLLs written in C++.

Share this post


Link to post
Share on other sites
You can probably find quite a few articles on this, I found a few just by searching around on google.

Combining Python and C++
Boost.Python

The Boost.Python one looks like what you would use to combine them, I must say I have never worked with python. So the concept of combining python and c++ has never really seemed to interest me.

The language LUA as you mentioned really is easy to implement, I have done it before; tons of resources out there that explain it. You can even build an interpreter, someone I know made a LUA byte code type of program, it broke a LUA code down into byte code and interpreted it.

Share this post


Link to post
Share on other sites

This topic is 4379 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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