Python or C++ ?

My nick is Cyanide. I’m from Turkey. My Turkish name is " Yağız ". I’m DxStudio and 3DGS expert user. I heard the new Panda3D engine.
I wanted to try. Very nice engine.

Pyhton is Good ?
Or C++ ?
Which is better?

( My English is Weak :C )

hi, and welcome to panda3d

panda was designed to be used with python. so python is the choice of language when it comes to panda.
if you are an experienced c++ coder you can use c++,too. but i recommoned python. there are many benefits provided by python,including fast prototyping, easy to learn and use.
speedwise it makes almost no difference since panda itself is already c++.

Thank You :slight_smile:

I’m a professional c++ user but it’s easier Pyhton arrived. :slight_smile:
I’ll ask a few more questions. :slight_smile:
Where is world editor ?
3ds files export to panda ?

for now there is no world editor.
there is a scene editor in development, it’s not finished but i think you can find information about it here on the forum.
for creating worlds you can use 3dsmax,maya, blender or any other modeling package.

for the 3dsmax exporter see the section in the manual.

Thank you very much.

This thread needs some c++ proselytism.

If you are a c++ pro as you say, you may find Panda3D in c++ very nice. The only problem is that not everything is documented in c++. That hasn’t been a problem for me so far, because the forums are very helpful when I need to do something in c++ and I can’t find how. So, when you are using c++ it takes a little more to find out how to do stuff. Work is being done in this sense and soon the c++ part of the documentation will be complete. In the meantime you’ll find that you can just read the python part and translate it, like:

Item.SetText(‘hey’) to item->set_text(“hey”);

Everything is very similar.

There is also some helper code that is in Python so there’s no c++ equivalent, like classes to make some shaders automatically and stuff like that, those are the downsides.

The upsides of c++ are, in my opinion:

  • It makes the game faster. This increase can be marginal but sometimes it’s a lot, if your project is CPU intensive (procedural content, a complex IA…). Note that there’s a way to do these parts in c++ and call them from python, but I don’t like dealing with two languages at the same time.
  • It makes the game size smaller (cause you don’t need to redistribute python). Silly reason though.
  • Deployment is cleaner (to install a Python game the user needs a PATH that points to a python installation). The panda installer makes all that for you, but still, I think it can lead to support complications.
  • Your code is gonna be easier to disassemble in python, if you care about that stuff. Definitely easier to hack, too, since people can just intercept python calls.
  • I find that rather than making me waste time, I save time in C++ in the long term, because it’s a compiled language so the strong typing, the fact that I have to initialize stuff, helps me fight bugs pro-actively. I also reject the notion that you save time in python because you don’t have to compile to try it. There’s a way to make your compilations instantaneous with the use of precompiled headers and turning optimization off. If you want advice on this, just ask.
  • I find it’s very easy to debug panda in c++, I’ve heard this is kinda tricky in python.
  • C++ gives me access to any library that I can need, because everything is in C/C++. Python users have to make a python version of the binding or wait until somebody makes it.

All in all, I’d say, go for C++ if your game has a special concept with a lot of technical complexity, otherwise, python may suit you better. But may want to go for c++ in any case for the reasons mentioned above.

One thing I’ll tell you, if you are gonna go for C++ instead of Python because of performance, think twice, most projects will get almost the same performance from python than from c++.

For the record I use c++ for everything in Panda (as you may have guessed).

Language preference is a very personal thing, and each person has his or her own reasons for preferring one language over another. Gogg raises many excellent points in favor of C++. I’d like to respond to a few of the less-strong points he raises. :slight_smile:

This may be true, but only if you don’t care about multiplatform support. If you want to fulfill Panda’s platform-agnostic promise, though, you will have a lot more work if some or all of your code is written in C++.

And I’m not even sure it’s true even if you’re only concerned with supporting Windows. packpanda does a pretty good job of building a fully self-contained Python executable; you don’t need to set PATH or any other environment variables to run the resulting Python program. In fact, it is just an .exe file just like any other, and the user will probably never even know he is running Python.

Also, the upcoming plugin/runtime system will actually make deployment easier for Python rather than C++, because Python code is easily packaged up into a redistributable p3d file. C++ code is possible too, but will require a bit more setup effort on the developer’s part.

I’m not convinced of this either. Disassembling code is easy in either language, and intercepting assembly calls is just as easy as intercepting Python calls. In Python, the hacker will have most of the symbol names available to him; but those are often available in compiled C++ too. I think this is pretty much a wash.

Strong typing vs. weak typing is a very personal preference too, and you find lots of religious debates on this subject over on the Java forums. Clearly both designs have their merits, as both designs continue to persist in many popular languages.

Language structure aside, though, the advantage of an interpreted language like Python is not so much the avoidance of a compilation step, but the fact that you can edit the code as you are running it, live. I have developed entire subsystems without restarting the application. It’s incredibly valuable to fiddle with parameters and algorithms and see the change immediately, in the current runtime session. To a certain extent, you can approximate this in a compiled language by temporarily extracting out the part of the application you are working on into its own standalone application, so that restarting this standalone application immediately puts you in the same environment each time, but this is more work.


Yeah, portability is another strong point of python, I left it out cause I’m not uncomfortable with some defines here and there and I’ve coded in Unix already so I know what to expect, which is why I didn’t even think about it, but definitely a plus.

Oh, well, I’m gonna blame some dutch type who told me that in irc. I probably misunderstood though.

It’s not about the symbols, python is much more expressive than c++. It’s easy to disassemble python, understand it, make a change and assemble it back. 20 times easier than with c++, really. (For anybody that wants to challenge this, we can make a cracking contest some day :stuck_out_tongue:). If your game is a rol game or something, no big deal, because it should be designed so that hidden information or automated input doesn’t give you an advantage. But if it’s a FPS, wall-hacks and aimbots are a real issue. And I don’t buy the argument that obscurity doesn’t help. I still remember the day that ID software released the Quake source and cheating became common in just a week. I’m talking of going from having the occasional cheater every once in a month to having 2 of them in every server playing all the time.

I agree that personal preference is a big factor, which is why I said “I find”. I prefer weak typing (PHP) for database driven web applications, for example. Because there you are only treating with the same types all the time, maybe you have a number but you know it’s a number because of the name, and maybe you have a string, but that’s about it, because you interface the subsystem via two objects, your output and the database connection.

However, when I’m using panda, sometimes I’m dealing in the same scope with a pickerRay, a collisionTraverser, a collisionHandler, a pickerNode, a pickerNodePath… And all those things are different types but conceptually they are closely related. It becomes very easy to make hard-to-find mistakes. Actually, it wouldn’t surprise if you tell me that python’s weak typing is the reason that panda has so many assertions(which is good.)

I’m glad you brought this up. I once tried python for a project because of this same reason. But I found that I had to do all of the work. I had to separate all that I wanted to edit live in a module, and that module had to be reloaded completely on every change. I also had to do the code that does this reloading. So I got back to cxx when I realized that I can do exactly the same in C++ with good old plug-ins. Am I missing something here?

EDIT: I want to add a disclaimer though, Python is still what I would recommend to most people. I was just pushing for c++ because the OP seemed to imply that he’s more comfortable with c++ than python currently, and in that case I think one should really go with c++.

This depends on your IDE. Some Python editors are better at handling this than others. It’s true that native Python doesn’t quite go far enough, for some reason; but that extra mile that makes all the difference is just a few lines of code away.

Within the VR Studio, we’ve written a customized Emacs python-mode.el file (provided in direct/src/directscripts) that provides a hotkey (control-c control-v) that will repaste the current class into the active Python shell, and then call direct.showbase.Finder.rebindClass(), to walk through the Python namespace, find all the references to the class, and replace all the old method pointers in the world with the new ones from the new class definition. This immediately makes the new class definition live without having to reload any modules. There are a few categories of changes that the Finder can’t handle automatically, but they’re pretty rare and it’s generally easy to deal with them by hand.

I believe some other people have integrated editors other than Emacs with the Finder in a similar way.


Ah, thanks, that’s very interesting. I use emacs when I’m not using msvc so I’ll take a look at that next time I do something in python.

For the record, ynjh_jo’s IDE does a pretty good job at realtime editing of panda3d games as well.

Thanks :slight_smile:


That’s pretty neat. :slight_smile:

If you don’t mind, I’d also like to hear other ways that you folks use Python/Panda3d in a realtime manner, and how your environment is setup. I’m not doing much of this yet in my game as it isn’t entirely necessary, but I would like to see how Disney (and maybe others) are leveraging the interactive nature of Python with Panda3d.