Jump to content
  • Advertisement
Sign in to follow this  
dmreichard

Combining a Language With a Language

This topic is 4599 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
Advertisement
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
Thank you GDKnight, I checked out the Boost.Python library, so far it looks very good. I'll be checking into those resources for Lua too! =)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!