Java vs Python

Started by
21 comments, last by boogyman19946 11 years, 9 months ago
I did a quick search on the forums and didn't see a relevant post about my question. The articles that were almost what I was looking for were at least 5 years old, so I figured it couldn't hurt to see what people think today.

First, a little background:

I'm a Computer Science student with most of my programming experience focused in Java and I've started learning game development by screwing around in Eclipse and trying to figure out some stuff on my own, as well as following some simple tutorials online to get me moving in the right direction. I also have a bit of experience with Python and I love the language.

And now for my question...

Basically I'm looking for opinions about using Python vs using Java for 2d game development. I'm really hoping to get people on both sides of the fence so I get hear the best and worst of both languages.

I won't be using any engines for my games (now or in the future) because I'm a bit stubborn and want to build all the engines I use myself. The most I would think about using would be Slick2d with Java or PyGame with Python.

Anyway, I hope you guys can give me some great insights on both languages. Thanks for reading
Advertisement
There is a reason both language and libraries exist. If one was universally better than the other, the other would no longer have any users and would fade away into obscurity.

Frankly, all we can give you is opinions. I can give you one small factoid, Java+Slick will be faster. If Python+PyGame have an Achilles heel, it's speed. Also, Java has much better tooling support. Python's IDEs mostly, well, suck. Or people just use a text editor. Java on the other hand has Eclipse ( which I hate, but others love ) and NetBeans ( which I love and others hate ), a good IDE will really help when you are starting out. Python does however have a much faster compile cycle, as well as an interactive mode, where you can basically type and interactive with code live, which is invaluable to a beginner.


Now for a matter of opinion. I don't like Python. I can't really get over that fact, I find it difficult to structure large programs in and I have been a member of the cult of the curly brace for far too long, so Pythons white space based program structure is anathema for me. That said, that is 100% opinion and applicable to only me.

In these threads we always say language doesn't really matter, and that C#, C++, Java and Python have all been used to make commercial games, but truth of the matter is, this really isn't true for Python. Python has been used *IN* commercial games, such as Civilization 4, but that was as an embedded scripting language, which is a much different task. The other often cited example is Eve Online, but there are two major caveats there too. First off, its actually stackless python they used and second... it's server side only I believe. There are some games, such as those from Disney using the Panda engine, but again, the engine itself is C++, and performance critical sections are written in C++, so Python is effectively being used as a scripting language in these situations. Once you take these examples off the table, I really cant think of a published game written in Python. The Blender Game Engine is powered by Python, but again, the engine is C++ and more to the point, I can't think of a single shipped BGE game either.

Not that the ability to publish a game matters when you are just starting out. Use what is most comfortable to you.
Thanks a ton for the input. Even though all the answers will be opinions, it will still help me out... especially because that is what I am looking for.


Python does however have a much faster compile cycle, as well as an interactive mode, where you can basically type and interactive with code live, which is invaluable to a beginner.


This sounds a lot like running a Java program in debug mode. You can change your code while the game is running and immediately see results. Is that the same function you mentioned above, or does Python do something different?


Once you take these examples off the table, I really cant think of a published game written in Python. The Blender Game Engine is powered by Python, but again, the engine is C++ and more to the point, I can't think of a single shipped BGE game either.



That's a really good point. I have heard these examples quite a bit, but I'm more concerned about indie games. I don't ever plan to work for a AAA gaming company. My goal is to own my own indie company someday with myself and maybe (not likely) one or two other people working with me. The examples given to argue for or against most programming languages are huge AAA commercial games.

I guess what I'm getting at is: Do you think Python (as well as Java) can handle what it takes to create a successful game like Meatboy, Braid, Castle Crashers, etc?

Thanks again for the input. More like this would be awesome!

You can change your code while the game is running and immediately see results. Is that the same function you mentioned above, or does Python do something different?

Python is interpreted, java is compiled (in reality it is far more complex than that once you start discussing bytecode etc). Java's debug mode is recompiling that section of script each time. Python you can launch the interpreter on its own without a .py file and just type print "hello world" hit enter and it prints hello world. It is very very different but incredibly useful, you claim to have had experience with python yet have never used this???


Do you think Python (as well as Java) can handle what it takes to create a successful game like Meatboy, Braid, Castle Crashers, etc?

Java will probably do that without any issues that I can think of.

Python will also be capable but its frame rate would be pretty miserable. Python IMO is the second most powerful language in existance (first would be either C or C++) because it can do just about anything, apart from games, its framerates are miserable. Even most of pygame is actually written in C and C++, pygame is a wrapper of SDL, basically you call a function from python, pygame takes that and calls the relevent sequence of functions into SDL which is for C and C++. Even then it isn't particularly quick although that might be something todo with how pygame was implemented, py-ogre I have seen get perfectly adequete frame rates and thats 3d so should be more demanding than pygame, only explanation might be that ogre uses hardware accelerated video and sound whereas pygame doesn't (I think SDL itself can support it but pygame doesn't use it)


I really cant think of a published game written in Python.

http://en.wikipedia.org/wiki/Frets_on_Fire < Ok open source, I'll give you that
There was also an old roll playing game made entirely in python but I can't remember its name.





I might not have shone a bright light on python for games but it does have its place in the game industry, writing things like scripts for how a level in a game should flow could be done as an external .py file to be loaded later.
Of the 2 I would look at using java. There is also jython (python running on the JVM) but I don't know if any graphics libraries work with that.
Also there is ironpython for .net and mono but good luck finding documentation on how to integrate .net/mono graphics libraries with it. I have seen someone using XNA with ironpython but as XNA is meant for use with C# most tutorials are also C#.

Python will also be capable but its frame rate would be pretty miserable. Python IMO is the second most powerful language in existance (first would be either C or C++) because it can do just about anything, apart from games, its framerates are miserable.


Nicely enough 6677 answers all of the questions for me. :)

That said, in regards to this comment, I really cannot think of a single metric by which I would rank C++ as the most 'powerful' language. If you mean in terms of speed you can achieve, that is remarkably arbitrary, as when it comes to parallel systems for example, erlang will spank it. When it comes to optimized code, assembly has it beat. You could mean "powerful" in terms of being able to express ideas as code, but even in this regard I wouldn't say so. The lack of a meaningful runtime will always handicap C++, so languages like C# can do things at runtime that C++ can only dream of, while languages like Ruby can express things that C# would have trouble with.

That being said, I will leave it there as I don't want to derail things further.



To directly answer the question "Do I think python could make Super Meatboy, et all.", probably not, at least not with PyGame. Someone could prove me wrong, I am by no means all that experienced on the subject, but I have yet to see a sophisticated PyGame game with good performance on moderate hardware.
I will just say that any performance considerations aside, it IS very difficult to manage a large python application. With Java or any other compiled language the compiler will find many of your errors for you. With python you will loath to change any interface or the signature of any function. Those changes will affect many different source files and you'll be debugging those changes instead of just fixing them before you can build it.

it IS very difficult to manage a large python application.

Oh yeah, its horrific. IDLE is a real poor IDE, and there aren't really any better ones. Your pretty much forced to have your entire project in 1 single file. Or you can split it by using modules but if your distributing a python game your already requiring the end user to install python, do they want to install pygame and manually install any custom modules your using? probably not.

The only IDE I've found that I like is SharpDevelop when I'm working on an ironpython project, I can split into multiple "class" files then which just isn't possible on CPython (The true name for the regular version of python) although it just doesn't seem to like being split up as much as C#/VB.net projects do, seems a little more prone to "this thing that you wanted, yeah I couldn't find it" when its right there infront of you. At least its a .exe I get out at the end of it, maybe the odd .dll



So thats pretty much a -1 on project management in python aswell. Nice language, excellent feature set, uber flexible. But stupid slow when you make games and its probably easier to arrange the specks of dust on your keyboard into the shape of your name than keep track of a python project with more than a handful of pages of code (unless you put giant ASCII logos in comment lines which then gets a bit ridiculous)
Eve, the space mmo uses python. For sane development, TDD is required. Jetbrains do a decent IDE if you like that sort of thing, called pycharm.

I've just reread this thread and a lot of the criticisms of Python are clearly from a position of total ignorance. All the code in one file? CPython makes module distro hard? Ugh.

Here's some quotes from people worth listening to;
http://www.python.org/about/quotes/

[quote name='smr' timestamp='1340656857' post='4952786']
it IS very difficult to manage a large python application.

Oh yeah, its horrific. IDLE is a real poor IDE, and there aren't really any better ones.
[/quote]
Komodo IDE is a pretty good option with a pretty decent feature set including code completion, debugging and profiling facilities. In addition to Python it also supports PHP, Ruby, JavaScript and others. At US$295 for the cheapest licence it isn't a cheap option, but I'd advise anyone working (or planning on working) extensively with the supported languages to give the free trial a go, as it's really is a solid offering.

Those looking for a free option might try Komodo Edit -- a free and open-sourced version of the above IDE -- obviously the free version has a significantly less impressive feature set (comparison), but it does still provide a good editing environment (syntax highlighting, code completion, etc.) which will probably be a more pleasant editing experience than IDLE.


There are some games, such as those from Disney using the Panda engine, but again, the engine itself is C++, and performance critical sections are written in C++
That's certainly true -- but is it really relevant that the underlying engine is written in C++ if the programmer only needs to use Python? In the case of Panda3d the lower-level C++ coding has already been done for you, and unless you're pushing the capabilities of the engine you should not have to resort to writing any C++ yourself.



Python definitely does have performance concerns to be aware of, but I don't think that they're necessarily the deal-breaker someone might believe having read through this topic.


Another thing to keep in mind when considering Python is deployment of the final product; there are various solutions to this, (mostly involving wrapping your project in an executable in some way) but you need to keep in mind that you would probably have trouble finding players if they were expected to sort out installation of the Python interpreter and required modules for themselves. This is a solvable problem, but it should be considered. Note that Java does also require the end users have a JVM installed.


All that being said, I'm firmly in the "it doesn't really matter" camp: you should pick whichever of the two you're most comfortable with, and you should be able to make games of similar quality and scale to the ones described using Java or Python ('though as mentioned, perhaps not using PyGame).

- Jason Astle-Adams

@jbadams

Your response has been the most helpful so far. Ever response in this thread has been, pretty obviously, biased and I appreciate your objective outlook. I expected a ton of subjective responses but it looks like you gave some much-needed input that really helps.

I'm still leaning towards Java, but you have definitely opened my eyes. Thanks for your time.

This topic is closed to new replies.

Advertisement