Questions about starting to use C++

Hi guys, So recently I’ve heard that C++ is WAY better than Python in many ways, AND nearly all businesses that involve game programming actually use C++.
I’ve been involved in GScript, and Python for quite some time.
So I have two questions i’d like stated quite clearly, If all possible.

So here goes questions 1-2:

1.) Is C++ so much better as they say it is?
If so, How?

2.) How is it that I can start using C++ in Panda3D?
This question isn’t so clear as far as what i’m asking for. So here I will explain at what I mean:
2.A) What is an application I can download to script in C++? (An example for Python I use is PyPE).
2.B) How do I start scripting in C++ on Panda3D? Do I just download this application asked for in 2.A, and just, start writing in C++? Or do I have to go through configurations for setting it to C++?

If I didn’t explain good enough, let me know, please.
This is something I seriously want to concider based on what you guys have to say.

Thanks, Luna.

Hi,

Neither C++ nor Python are better than each other. C++ and Python both have specialties and benefits over the other. Silly analogy: (C++ is not Godzilla, nor Python a rabbit, but both are yin and yang.)

You need to choose which language you will use, based off your requirements and what you hope to get out of your experience.

Some benefits of C++ are:
(Speed) many things/algorithms you implement in C++ will run faster than the same implemented in Python. This is due to C++ being compiled into native machine code, where as Python is interpreted by the Python Interpreter.

(Game-dev jobs) Dare I say, many game programmers and developers use C++. This is due to it's speed and performance, and large video game companies, need and want as much speed and performance as they can get. "Next Gen" games, or AAA titles, need this.

Some benefits of Python are:
(Easier to program) if you are a beginner to computer programming, you will likely encounter many less problems using Python than you would using C++. Python is a much simpler language to understand than C++ and also abstracts away more low-level things, that you would have to know and understand when programming in C++.

(Cross platform) if you use C++, you will need to ensure your code both compiles, and is compiled on, any platform which you want your game to run on. (Windows, Linux, Mac) Since Python is interpreted, your code runs anywhere that the Python interpreter runs (with the exception of C++ extensions). Meaning less deployment problems for you.

Python is easier to learn, and is much speedier to develop in. C++ can perform most, if not all, operations faster than Python can.

You would be looking for either a C++ compiler, and/or an C++ IDE or other code editor. This depends on which operating system you are running. (GCC for Linux, Visual Studio for Windows) You can find instructions in the Manual under the documentation tab at the top of this page.

There would be a setup process that includes linking the panda3d C++ libraries, and is very operating system and compiler specific. A good starting place would be to look at the Starting Panda3D page here, and then clicking the C++ tab at the top of the page.

It is very important to make an educated decision based off what the requirements are for your project or end-goal.

I’m willing to discuss more in depth about area’s that interest you most, so please feel free to respond back with your own comments and concerns. I would also recommend that you fully understand whatever programming language you choose before attempting to build a video game or other multimedia project. Or at the least get a good knowledge for computer programming in general.

Hope this helps,
~powerpup118

[edit] Bah, ninja-powerpup! :stuck_out_tongue: [/edit]

(For the sake of providing qualifications, I’ll note that I’ve programmed in C++ as well as scripted in Python.)

First of all, as implied in the note above, using C++ is programming, not scripting. In some cases the difference may be minimal - even entirely debatable - but in general I think that you’ll find them referred to separately so.

As to game developers using C++, I’ll admit that my own experience is limited to only one small studio, but from that experience I’ll say that a number of languages - both programming and scripting - tend to get used. If I recall correctly I ended up using Java, TorqueScript and a bit of C++, Objective-C and C#. I even touched a very little bit of Python, PHP and SQL, as I recall. Nevertheless, given the principles learned and the relation to other languages, I do think that either C++ or Java would make a decent “core” language to learn.

On the plus side, if you do pick up C++ it should help you to pick up further programming languages in the future.

I’m inclined to say that this depends on what your goals are, and how one defines “better”. Or, put another way, it depends on the circumstances. A few differences that come to mind follow:

C++
Well-written C++ code should be rather faster than Python (although one can very much write slow C++ code too, I do believe).

C++ also arguably provides greater control: you’re working at a lower level, and thus have the option of finer manipulation of the inner workings of your code.

There is a price to pay for the power and speed, however: C++ is rather more complex than Python, and provides a number of ways to break things that I don’t think are present (or at least easily accessed) in Python.

Python
Python, on the other hand, is rather simpler than C++ - and thus easier to work with.

It also allows you to simply run your program: C++ code calls for compilation first, which, depending on your project, can potentially take a noticeable amount of time.

Concluding thoughts
If your goal is simply to make games, and you don’t have significant performance issues to deal with, Python will likely serve rather well. If you do, however, find Python simply too slow, or you want greater control, you might find C++ useful to you.

… Where to start. ^^;

First, please note that C++ is not, I feel, as easy as is Python. It’s a full programming language, not a scripting language.

However, if you do want to learn it, I suggest getting a decent free compiler (preferably a full development environment) - it’s been some time, but I recall Microsoft’s free version of Visual C++ being rather good - and then pick up some tutorials.

I strongly advise against attempting to jump straight into Panda with C++ - you might well make progress, but there are things - including dangers - that you might miss by not doing so that a good set of tutorials might help with. (I’m afraid that I don’t know of any offhand, although you might find some on GameDev.net)

If you don’t mind taking a relatively long but likely easier approach, you might consider learning Java before C++, but starting with C++ is, I think, quite feasible.

Yes, I’d love to try out C++, as it may be more intersting to me. GS is much more like C++ than Python is, Which means it can be easier for me, personally, to understand.

If you’d please tell me how I can start using C++ in Panda3D, That’d be great.
Again, I ask this because i’m not sure if i need to go through configuration to set C++, Or whatever it is. Because for Python, All I did was download PyPE and save a file as .py, Is it that simple in coding in C++?
If not, What do I need to do?

What can I download to code in C++ just like I can in PyPE?

I apologize for answering without answering some (admittedly most) of your questions… I’ve updated my post right after I realized I did and you’ll find I answered them to the best of my knowledge. ^^

Hope this helps,
~powerpup118

It looks like we posted at more or less the same time, so I’ll point you to my post just above yours, in which I (think) that I answered those questions to some degree.

However, in brief:

  • Coding in C++ isn’t as simple as coding in Python, I fear - it’s not quite as simple as writing a code file, saving it and running it.
  • You might try Microsoft’s Visual Studio for a decent IDE.
  • I strongly recommend starting with C++ tutorials rather than diving directly into C++ with Panda if you haven’t used C++ before; I don’t know GScript myself, but a quick search indicates that it’s a relative of Java, which might at least provide you with some background.

Alright, I am having a bit of a confusion understanding what is meant by this “compilation” and what it is.
However, that’s the least of my worries at this point.
Since you stated Panda3D may not be the best for C++ use, do you happen to know a good program like panda3D I may be able to use? Otherwise, I don’t see how I’d even be able to see what I’m typing in, or test anything at all.

Thanks for your guys’ help by the way,
I seriously do appreciate it!

Oh, I don’t mean to suggest that there’s anything wrong with Panda3D when used with C++ - I imagine that there’s no more wrong with it than as used with Python. Rather I mean to convey that I feel that learning C++ is a task sufficiently large and complex that attempting to do so by using it with an engine seems like a potentially poor idea. I don’t recommend starting with an engine at all, but rather starting with basic tutorials and picking up a good foundation in the language before you start putting it to use in Panda.

As to compilation, in brief and as I understand it:
Compilation is the process of converting source code - C++ code, for example - into a form that the machine understands.

The computer doesn’t understand either Python or C++; in order to run either, we want to convert the code into something that it does understand. In the case of C++, this is a direct process: we take the C++ code and turn it into code that the computer can understand.

On the plus side, this can be fast. On the down side, this means that you don’t get to take that compiled version to a computer running another operating system and expect it to simply work.

A language like Python, however is interpreted: it’s converted to a form that is read by another program (the Python interpreter, if I recall the name correctly for Python’s case). This has some advantages - including allowing one to move files between operating systems - but is also potentially slower than just running a program directly.

Wikipedia seems to have a rather in-depth article.

PS: Please forgive me if I’m at all brusque, or overly ambiguous - I’m terribly, terribly tired at the moment. ^^;;;

I think one critically important thing, that I did not see mentioned, is that Panda3D itself is written in C++.

When you use Python with Panda3D, you are only using Python as a top layer to do things which are not very expensive to compute. All of the performance-related tasks such as physics, sound, animated models, rendering, and so on, are already written in C++ as part of Panda3D, and optimized for speed. If you have a simple game with a character running around in an environment, you are not going to notice any performance difference by rewriting it in C++.

Unless you are already proficient in C++, the best way to use Panda3D is with Python. This will allow you to iterate on your game very quickly. If you find that a certain part of your Python code is causing performance issues, then it is possible to write that part of your game in C++ and use from Python in the same way as you use the Panda3D engine. Also keep in mind that some parts of Panda3D exist only in Python. These include anything you import from the “direct” module, such as the Actor class.

If your goal is to get a job as a programmer at a game studio, writing stuff like rendering engines, particle systems, physics simulations, then yes you will most likely need to learn C++. There are also positions in most game studios that use scripting languages. For example: writing game logic, scripting cutscenes, or designing missions. I agree with the others, if you want to learn C++ then learn C++ separate from Panda3D at least until you are comfortable enough with it to write some simple programs.

Based on the information given,
I think I’ll just stick with Python for now.
I did try to use C++, but I couldn’t figure out how to start and download some stuff.
Besides, it’ll save me a lot more time at what I’m doing.

Maybe ill try C++ later on in life.
Thanks again for all the help, guys! I appreciate it.

When trying to learn C++ I’d suggest trying without Panda3D, as C++ itself is quite complex, IMHO, and Panda3D only adds an additional layer of complexity on top.

Back to the topic with AAA games: Many game developers are currently switching to scripting engines for the benefit of development speed. It’s better to develop a game in six months that just runs fine rather than needing an year for five percent better performance.

Also a small difference between C++ and Python: C++ is a strictly typed language whereas Python is dynamic and duck-typed. I wouldn’t say either one makes development easier, but there are people who prefer the one or another way.

I always said that Python is for stuff that needs to be written fast, while C++ is for stuff that needs to run (very) fast. If you need both, you better make sure you’re skilled enough to write fast code fast in C++.

I recently took a dive into C++ (for the first time in years) because I needed to speed up my lightmapper. Admittedly, it was much more user friendly then I anticipated, at least after getting over the interrogate voodoo with the help of our invaluable rdb. I hope that eventually I can learn enough to start messing around with Panda’s entrails. This is one of the greatest benefits of knowing C++ (and C) – everything’s written in it, so you can dig deeper into projects, help with their development or just shape them to your will.

Funnily, Unreal Engine 4 has retired UnrealScript and will now be 100% c++ operated. However, Kismet is now used to write… everything and spits out c++ code, which is then compiled asynchronously and the changes are loaded as soon as building is finished.