Python vs. C For Game Programming

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 2545 Views - Last Post: 03 February 2013 - 07:10 PM Rate Topic: -----

#1 br3tt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-February 13

Python vs. C For Game Programming

Posted 02 February 2013 - 10:35 PM

Hello there, I'm Brett. I started coding this past July, and have learned HTML and CSS. I am looking to move on, and have looked into Javascript, which I dislike, Python, which is fairly easy and seems useful, and possibly C, which would prepare me for Java. I would like to hear your(Any Game-developer) opinion on which direction I move on to. I'm thinking C or Python. If you have any reasons why I should choose one over the other, or learn something else, I would love to here from you!

This post has been edited by macosxnerd101: 02 February 2013 - 11:26 PM
Reason for edit:: Please use a descriptive title


Is This A Good Question/Topic? 0
  • +

Replies To: Python vs. C For Game Programming

#2 Nekroze  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 170
  • Joined: 08-May 11

Re: Python vs. C For Game Programming

Posted 03 February 2013 - 12:07 AM

First up I doubt anyone would really use C for any modern game, C++ is what you would be using.

C++ is great for performance and there is a lot of support out there, however it has many issues that a lot of people find annoying or hard to work get the hang of. More information about this is detailed HERE and HERE.

Python has much less issues and they are in general not as annoying as C++ issues. However one large problem with python for serious game development is performance but more on that in a moment.

Python is a very nice and easy language that works quite well for game development especially for learning, for this I would recommend using Python and Pygame which is a wrapper around SDL and allows you to quite easily develop 3d games of moderate complexity. Some things require more power such as a very complex 2d game or a 3d game and for this I would recommend Pyglet which is a wrapper around OpenGL for python and also has some nice abstractions so you dont get stuck re-inventing the wheel for some of the most basic things for each project. There are alot of support and examples for both around the place.

Pyglet however is not an entire game engine but can be used to more easily make one compared to doing so in C++. There are a few good game engines if you really need them that support python such as Panda3d and Python-Ogre although I have not had much use of either yet so i cannot comment on their pro's and con's nor any decent alternatives.

The good thing about using pyglet or using opengl from any language is that if it is done right you can keep the language specific performance issues to a minimum as most things can be done on the GPU in some way. So even though python is much slower the C++ the difference can be in some cases negligible.

When it comes to making python faster there is a great system call Cython which allows you to turn any python code into C/C++ and then compile it, this can provide some decent speed ups but when you use some of the cython specific features from within your code you can massively increase performance.

I have written a blog post where I evaluate the different methods of using cython and talk about how much of an annoyance they are when developing compared to standard Python then show some simple performance benchmarks to give an idea of the effect of each method.

The blog post can be found HERE and the source code for the test are provided as well.

Overall I would say go with Python, even if it is a stepping stone on to using C++ later on. At your point I would be more concerned with learning how the games work and how they are made more generally then learning a specific language for it. Besides if you later learn C++ you can combine that with cython or write python modules in C++ that allow you to use any C++ code at near full C++ speed from within python. This is something that is becoming popular so as to allow for easy work on the higher levels of the game and the low level nitty gritty stuff like how graphics are rendered are all handled in full speed C++.

No matter what you choose to do I would just be more concerned with learning how the games work rather then getting bogged down in language details until you understand where you want to go with it. Which I submit is easily accomplished with Python.

This post has been edited by Nekroze: 03 February 2013 - 12:08 AM

Was This Post Helpful? 1
  • +
  • -

#3 br3tt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-February 13

Re: Python vs. C For Game Programming

Posted 03 February 2013 - 12:12 AM

I think I'm going to learn Java instead of C++. Would it be possible to develop a game using Java and Python, Python for the source, and Java for most of the other work?
Was This Post Helpful? 0
  • +
  • -

#4 Nekroze  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 170
  • Joined: 08-May 11

Re: Python vs. C For Game Programming

Posted 03 February 2013 - 12:17 AM

Maybe through Jython that could be possible but I am not sure.

I am not sure why you would really want to mix the two there seems to be little point and its not something that is well supported if it can be done.
Was This Post Helpful? 0
  • +
  • -

#5 br3tt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-February 13

Re: Python vs. C For Game Programming

Posted 03 February 2013 - 12:29 AM

What languages would I want to develop a game, if I used multiple ones?
Was This Post Helpful? 0
  • +
  • -

#6 Nekroze  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 170
  • Joined: 08-May 11

Re: Python vs. C For Game Programming

Posted 03 February 2013 - 12:37 AM

Well like I said first, Python and Cython would be best for performance and ease of development but don't worry about Cython until you know your doing something that will need to be sped up.

I don't know why you would be so set on using multiple language though, I doubt anything you do straight away would push the limits of a language like python or java and even if you do in the case of python it is trivial to use Cython on some of the slower bits and then keep on benefiting from the nice syntax of python.

For the record however Jython does allow you to write code in both Java and Python as detailed here Why Jython.

However its all compiled down to java byte code and may not be able to get the same performance of Cython or C++. But you are still using 2 languages that get compiled down to the same thing and i don't understand why you would combine those two unless there are particular java libraries that you must use. If you are doing the java and the python yourself you are just adding complexity for the sake of it.
Was This Post Helpful? 0
  • +
  • -

#7 br3tt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-February 13

Re: Python vs. C For Game Programming

Posted 03 February 2013 - 12:40 AM

I would like to create a Virtual World, so I didn't really know. I'm pretty knew to programming. Could I still use Flash swf's in PyGane? Swfs would be for items in game, or would I use like Cinema 4d?
Was This Post Helpful? 0
  • +
  • -

#8 Nekroze  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 170
  • Joined: 08-May 11

Re: Python vs. C For Game Programming

Posted 03 February 2013 - 12:53 AM

You seem to have mixed thoughts here.

Firstly you seem to want to do a 3d game, this can be rather hard to start with. It would help to use a graphical library that is designed to be very easy for the newbie.

Most people will recommend doing 2d before moving to 3d.

I don't think you can use .swf files from python because they are for different things then just sharing an image for a 2d sprite and are needlessly complex for doing so.

Cinema 4D is a 3d modelling and animating suite and as such is only useful if you are making 3d games which is very complex to start with. Also I have never heard Cinema 4D recommended to newbie, generally Blender is a great starter as it is entirely free and can do pretty much anything that the others can do as well as being well developed and documented for beginners.

Because you have some mixed ideas on what you are doing it is hard to give you a specific answer without taking some decisions away from you. This is however to be expected because you are new and these are questions that almost no newbie can answer but unfortunately are very useful to know the answers to.

So do you really want to dive right in to 3d games, it can be rather hard to learn the language and all the 3d stuff at the same time. If you are so set on Java then just use java, don't try and learn 2 languages at once as well as learning how to make games. Will you really be using the entirety of a modern computers processing power, you will likely be fine using a easier and slightly slower language rather then going straight to C++.

Choosing the harder options are always appealing but they really do make it much less likely for you to really learn anything other then programming sucks and is hard.

If you cant get the answers to these things then the best i can say is give python and pygame a go then move on to python and pyglet and maybe learning how to use cython along with python to make it faster where needed. This way you ease into learning things and you can see and play your progress the whole way through.

Once you choose what system and language you are going to use then you decide how you are going to make your assets. Most every asset in a game from any game engine can be made with blender and photoshop/gimp (payed/free respectively).

After doing some work in these and getting some good results then look at other things to learn with your new knowledge.
Was This Post Helpful? 1
  • +
  • -

#9 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7765
  • View blog
  • Posts: 13,131
  • Joined: 19-March 11

Re: Python vs. C For Game Programming

Posted 03 February 2013 - 12:55 AM

I don't do any game programming, so I can't help you on that front, but it seems to me that you would do best to learn some damned thing and start using it and see what its strengths and weaknesses are, rather than spending a lot of time trying to figure out what's the right thing to learn.

For my part, I'm moving away from Java, but that doesn't mean I wouldn't advise you to learn it. Java is a really good base language to have - partly because you can really learn a lot of core stuff in it that's actually harder to learn in a language like python, but also because it's going to be the glue language for the jvm stack for a long time to come even if - as I think it will - Java itself becomes less and less important.

If you spend a year getting really good at Java and then decide that you want to work in python or something else, you've lost nothing. Getting really good at a language is always good for you, Java will always be paying proposition in your lifetime, and burning a year now is always easier on you than burning it later. So just dive in and do it to the hilt, and when you feel like you really know the language you can decide whether to keep on straight or hang a left into something else.
Was This Post Helpful? 0
  • +
  • -

#10 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Python vs. C For Game Programming

Posted 03 February 2013 - 08:02 AM

View PostNekroze, on 03 February 2013 - 03:07 AM, said:

First up I doubt anyone would really use C for any modern game, C++ is what you would be using.

Yes, C is still most certainly used in game development for a number of reasons, including:

1. Library compatibility. Some libraries are specifically written in C to avoid some features of C++ like name mangling as a consequence of polymorphism.
2. It's still easier to get closer to the hardware using C.
3. Sometimes you just have to link in C over C++.

To the OP, people can't really direct your learning path. If I'm totally honest I don't believe you should be thinking about games yet until you have a solid foundation in a language. Pretty much any language will let you write a game, but the overall quality of that game will be greatly affected by the chosen language in terms of performance and features.

Spend your time learning a language thoroughly first.
Was This Post Helpful? 1
  • +
  • -

#11 br3tt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-February 13

Re: Python vs. C For Game Programming

Posted 03 February 2013 - 02:02 PM

I know that, but what language should I go with? I read Python is easy too learn, and it seems pretty easy to me.
Was This Post Helpful? 0
  • +
  • -

#12 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3490
  • View blog
  • Posts: 11,902
  • Joined: 12-December 12

Re: Python vs. C For Game Programming

Posted 03 February 2013 - 02:11 PM

View Postbr3tt, on 03 February 2013 - 02:02 PM, said:

I know that, but what language should I go with? I read Python is easy too learn, and it seems pretty easy to me.

Doesn't this answer your own question..? Master Python first!
Was This Post Helpful? 0
  • +
  • -

#13 br3tt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-February 13

Re: Python vs. C For Game Programming

Posted 03 February 2013 - 02:34 PM

Could you recomend a few good sources to learn Python at. I currently have Codecademy and Thenewboston.
Was This Post Helpful? 0
  • +
  • -

#14 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3490
  • View blog
  • Posts: 11,902
  • Joined: 12-December 12

Re: Python vs. C For Game Programming

Posted 03 February 2013 - 02:46 PM

View Postbr3tt, on 03 February 2013 - 02:34 PM, said:

Could you recomend a few good sources to learn Python at. I currently have Codecademy and Thenewboston.

I understand people like Python The Hard Way. You could run through that.

I like The Quick Python Book but it is obviously not too detailed, but still has a lot of useful information.

There are tutorials here at DIC as well.

If you want an IDE then I use Komodo Edit for Python. Install the editor then install ActiveState Python (ActivePython) on top of this and you will have syntax highlighting, intellisense, etc.

This post has been edited by andrewsw: 03 February 2013 - 02:52 PM

Was This Post Helpful? 1
  • +
  • -

#15 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Python vs. C For Game Programming

Posted 03 February 2013 - 05:15 PM

View Postbr3tt, on 03 February 2013 - 05:02 PM, said:

I know that, but what language should I go with? I read Python is easy too learn, and it seems pretty easy to me.

Didn't you pay attention to a word I said? It's bizarre you should ask what I just answered after claiming 'you know that'.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2