Sign in to follow this  
Rouge_Raven

Pro's & Con's of Python, Java, C++?

Recommended Posts

Pros:
Python: Easy to learn, generally a beginners language
Java: Very portable, and also quite easy
C++: very powerful, you can do almost anything with it

Cons:
Python: It's interpreted, so the user must have the interpreter and the game is automatically open source
Java: You can't access memory like in C++ (no pointers)
C++: Can be rather difficult to learn

Share this post


Link to post
Share on other sites
I think Vampire: The Masquerade was done in java (if I recall correctly, it's been awhile.)

And the recent Battlefield 2 uses python for some stuff, such as stat exporting.

Share this post


Link to post
Share on other sites
Pro's

Python: Easy to learn and code, it's OO, so it has the functionality of C++. Faster development time because of ease of code.
Java: Platform independant. C like, can be confusing. It is also OO. Also very internet capable. Can develop applications for the web.
C++: Very, very powerful. Can do anything Python and Java can (except internet capabilities of Java). You can do a lot Generally platform independant, you just might need to re-compile it. Lower level than Java and Python. Also more efficient. C++ is probably the most used language of any.

Con's

Python: Interpreted, so it's slower at runtime. Making it crackable so you can grab the source.
Java: Limited, no pointer access. No pointer access because of its internet applicability. Also interpreted.
C++: Hard to learn (not to me :/ ).Because of it's a lower level language, it requires more code. Because of the design reading the code can be mind boggling.

P.S.: People usually use Python as a Moding language for there game because of it's easiness. Plus it's OO and I guess would work well with C++.

Share this post


Link to post
Share on other sites
Quote:
Original post by sykonet
I think Vampire: The Masquerade was done in java (if I recall correctly, it's been awhile.)


Not true.. They used Java as a scripting language, while the core of the game was written in C++ Link

Don't get me wrong here, as I think that Java is the coolest language of them all. The only time I would recommend you to stay clear from Java is when writing a new OS...quite frustrating to do such tasks without pointers :) Java does have some performance issues when compared to languages compiled to native code (binary format), atleast when it boils down to raw computing power - but I feel more comfortable with Java. The only drawback is that I think it's easier to write bad (as in slow) code with Java.

Share this post


Link to post
Share on other sites
Quote:
Original post by Oberon_Command
Python: It's interpreted, so the user must have the interpreter and the game is automatically open source


The interpreter itself is a 1.78MB DLL, which isn't that big a burden.
You can distribute the .pyo instead of the .py if you wish.
And the application definitively isn't "automatically open source".

Share this post


Link to post
Share on other sites
Quote:
Original post by dbzprogrammer

Java: Limited, no pointer access. No pointer access because of its internet applicability. Also interpreted.


Technically, it's not interpreted! Java is compiled into bytecode and executed through a virtual machine (kind of a software CPU). It's not only running your code, but also trying to optimize it on the fly. In theory, a java application could perform better after n hours of execution because of this.. Sadly, it doesn't work that way..atleast not with Eclipse or Netbeans [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by dbzprogrammer
Java: Limited, no pointer access. No pointer access because of its internet applicability. Also interpreted.


I don't know why people list 'no pointer access' as a con. It's really not as big a deal as people think it is. You don't need pointers in Java, so you don't miss them at all. When you program in Java, think in Java. If you think in C++ while cranking out Java code you'll never be an efficient Java programmer. And for the millionth time - it's not interpreted anymore!.

My perspective of Java cons, for game programming:

* not currently available on consoles

* online distribution issues - Do you require the user to download the JRE if it isn't installed already, or do you bundle it with your app? For a budget game this could make or break you. For a packaged CD it's not an issue.

* lack of third party game dev tools - while there are some fantastic IDEs for Java, game-specific tools are lacking. There's are a handful of open source and commercial 2D/3D game engines being developed (I don't believe any of them complete), and some cross-platform native bindings for OpenGL, OpenAL, and JInput, but that's it. Contrast that with the plethora of C++ game tools available.

* bad reputation - most gamers know nothing of the tech used to create games, but I have seen on some gaming message boards that Java isn't as unknown as one would think. The problem is that those gamers who do know about it only have heard that 'Java is too slow for games'. They automatically dismiss any game they hear is made with Java.

* easy to learn, difficult to master - programming in Java requires a different mindset. Some things you might have learned through another language just do not apply in Java, and can hurt you rather than help you. For example, you have to learn to program for the GC, something you need not be concerned about in C++. Then there's some things that are Java-specific that you need to learn to handle. For example, many people have the misconception that because there's no pointers in Java you can't have memory leaks - not true.

Pros:

* reduced development time compared to C++ (not so much Python ;)) - generally, if you know what you're doing, you can be more productive in Java than in C++. I know C++ programmers who will dispute that, and that's why I qualify it with 'generally'. Java has a robust API that simplifies a lot of things for you, things that in C++ you would have to implement yourself or license a third party library for. And I have found that design implementation comes much more naturally when working for Java (but that's me, and others may disagree).

* superb development tools - there are some excellent tools you can use throughout the development cycle that blow away anything available in C++. While commercial versions are available, there's almost always a quality free alternative. IDEs (such as Eclipse, Netbeans, and IDEA) that are packed with features (refactoring, automatic compilation, semantics checking, etc...), comprehensive debuggers and profilers, GC profilers (these are great for fine tuning large apps to reduce memory consumption and improve performance). Lots of goodies (and they actually can be quite fun to play with).

* safety nets - there's quite a number of safety checks behind the scenes (such as array bounds checking and null pointers - Java doesn't have pointers like C & C++, but a similar, though safer, concept in that every class instance is a reference that is passed by value). C++ programmers would likely list this as a con for taking away control (i.e. not giving them a choice as to when to do bounds checking), but many Java programmers will tell you it's great not to worry about that kind of stuff. Let Java handle it all behind the scenes while you move on to other things (another step toward higher productivity). Plus, the runtime compiler can optimize away some of these safety checks when the program runs.

* no pointers - yes, I see this as a pro! There are several common mistakes that can cause hard to find bugs in C and C++ when using pointers. Sometimes you don't even know of it until you release the app inton the wild (buffer overflows anyone?). But it's not a panacea, as you can still have NullPointerExceptions thrown when the user runs the app (which is equivalent to an access violation or segfault), and you can still have memory leaks (via dangling references).

A lot of what's good/bad depends upon your perspective. Somone with no experience either way (a total newb!) has a clean slate with no bias. As you get familiar with one language or another, you'll start to develop preferences and dislikes. You'll find that what you think to be a great feature another may think is restrictive or asinine. One man's trash is another man's treasure, and all that. The best people to get opinions from, IMO, are those who have experience with multiple languages and know how to use them well. They often will have developed a balanced opinion and know when to use the right tool for the job. People who religiously defend one language over another generally can be ignored, as their opinions are horribly biased - and unfortunately you will find a lot of that here. I try to keep my opinions balanced, but I do favor Java over C++ so you can surely consider me biased. That's why I don't offer any opinions on C++ here (the cons list would be too long :)). As for Python, I enjoy using it and find it to be a more productive language than Java, but I haven't really used it much in game development (a bit of scripting, for which it is an excellent choice).

Some commercial Java games: Tribal Trouble, Puzzle Pirates, and a few titles from Puppy Games. All of these games were developed by indies, but Three Rings recently shipped a box version of Puzzle Pirates in a publishing deal with Ubisoft.

I don't know of any commercial Python games, otherwise I'd link some for you.

Personally, I've made the switch to D. I use it for all of my personal projects now, including game related stuff. I find it to be a nice middle ground between Java and C++. But it's not for everyone. It is still in development (not yet 1.0), and there are few resources available for learning it. Just as Java requires a different mindset, D requires you to think in D to be effective with it. So maybe it isn't the best language for beginners right now.

Share this post


Link to post
Share on other sites
Quote:
Original post by Rickmeister
Quote:
Original post by sykonet
I think Vampire: The Masquerade was done in java (if I recall correctly, it's been awhile.)


Not true.. They used Java as a scripting language, while the core of the game was written in C++ Link

Don't get me wrong here, as I think that Java is the coolest language of them all. The only time I would recommend you to stay clear from Java is when writing a new OS...quite frustrating to do such tasks without pointers :) Java does have some performance issues when compared to languages compiled to native code (binary format), atleast when it boils down to raw computing power - but I feel more comfortable with Java. The only drawback is that I think it's easier to write bad (as in slow) code with Java.


As I said, I wasn't sure, I looked at some of its files a long, long time ago and remember seeing some java stuff in there, so...yeah, I guess I was wrong, well, half way.

Share this post


Link to post
Share on other sites
Well, since Aldacron has given The Definitive Guide to Java, I shall attempt to do the same thing for Python.

Python is, as has been said, easy to learn, easy to write programs in, and very slow compared to the other two languages. However, depending on what kind of game you want to make, speed may not be as much of an issue (ie for a text-adventure or turn-based strategy game/dungeon crawl), and in that case you will probably save a LOT of time by coding in Python. It is specifically designed to give you shortcuts that aren't avaliable in lower-level languages like C++ and Java.

Anyway, the cons for Python are much the same as Java:
*You must distribute the interpreter (or at least the DLL) with the program, though it's much smaller than Java, and there are programs (py2exe, I think it's called) that will package everything up for you

*Not avaliable for consoles (works just about everywhere else though)

*Programming in Python is easy, optimizing it is a lot harder. A lot of stuff goes on under the hood, and things may not happen the way you think it do; a complete understanding requires a good look at the interpreter internals. This is of course not necessary for just using it, but the learning curve for figuring out how it works may be a bit high.

*It's slow. Very slow, compared to C++. Java is slow too, but Java can be made fast if you know how to do it (most people don't know or don't bother, it seems). In Python, the way to get something done fast! is to re-code it in C.


The pro's:
*It's a wonderful langauge, well-designed, clear, and easy to program in. You can write things FAST in Python.

*There are lots and lots of lovely libraries for it. If you want to do something, there's probably a library for it; anything from graphics to networking to XML parsing to email to data structures...

*There's just as much lovely documentation for it, and the community is both large and helpful.

*Whenever your program fails, it will print a simple, clear exception message, not C/C++'s "Segmentation fault" or Java's 100-line backtrace.

*Dynamically typed... Yes yes, this can be a bad thing too, but not having to declare what types you're using when and how can save a lot of time, and make the program easier to read.

*Garbage-collected. Never get dangling pointers.


Python isn't what you want in every situation, but when you do get the chance to use it, it makes life amazingly easier.

Share this post


Link to post
Share on other sites
Quote:
Original post by Aldacron
I don't know why people list 'no pointer access' as a con. It's really not as big a deal as people think it is. You don't need pointers in Java, so you don't miss them at all.


More accurately:

Java does all the common pointer operations for you behind the scenes when you write something normal looking, and it's easy with practice to refactor unusual pointer operations into more common ones - trust us on this one. As a con, you lose control over the number of levels of indirection (because they get automatically generated for you, and to avoid it you have to fight the language and write in a more procedural style); as a pro (a big pro) you don't have to distinguish * from [], . from ->, worry about pointers vs. references, or in general write extra punctuation that C++ forces on you - plus, you get well-defined behaviour out of a bad pointer (although it still normally indicates a bug you have to fix).

Quote:
When you program in Java, think in Java. If you think in C++ while cranking out Java code you'll never be an efficient Java programmer. And for the millionth time - it's not interpreted anymore!.


Very, very true. RAII is largely at odds with the GC approach - both work if you design for them and use the tools you're given the way they're meant to be used.

Quote:
My perspective of Java cons, for game programming:

* not currently available on consoles


It *is* available on handheld devices. :)

Quote:
* online distribution issues - Do you require the user to download the JRE if it isn't installed already, or do you bundle it with your app? For a budget game this could make or break you. For a packaged CD it's not an issue.


Every common OS installation I can think of these days installs a JRE.

Quote:
* lack of third party game dev tools - while there are some fantastic IDEs for Java, game-specific tools are lacking. There's are a handful of open source and commercial 2D/3D game engines being developed (I don't believe any of them complete), and some cross-platform native bindings for OpenGL, OpenAL, and JInput, but that's it. Contrast that with the plethora of C++ game tools available.


This is true. The games industry moves *slowly*. People don't know how to use the C++ standard library (with std::vector et al) properly in games, so they forget about it entirely, and end up basically writing C.

Quote:
* bad reputation - most gamers know nothing of the tech used to create games, but I have seen on some gaming message boards that Java isn't as unknown as one would think. The problem is that those gamers who do know about it only have heard that 'Java is too slow for games'. They automatically dismiss any game they hear is made with Java.


Another problem is that by the time people began to come to their senses about this, C# had already started to make waves.

Quote:
* easy to learn, difficult to master - programming in Java requires a different mindset. Some things you might have learned through another language just do not apply in Java, and can hurt you rather than help you. For example, you have to learn to program for the GC, something you need not be concerned about in C++. Then there's some things that are Java-specific that you need to learn to handle. For example, many people have the misconception that because there's no pointers in Java you can't have memory leaks - not true.


Right. Another thing is that you have to become comfortable with the idea of aliasing objects most of the time rather than copying them. This can actually lead to more memory-efficient designs, because the effort involved is less - in C++ you either bite the big bullet of managing pointers somehow, or bite the small bullet of the Rule of Three (and sometimes people just blow that off, and then don't understand where the bugs come from :) ). Because of the Java object model (which is quite similar in form to what Python does, btw), it's a lot easier to share things that don't need to change.

And yet another thing is that you have to become comfortable with the idea of object identity vs. object equality.

Quote:
* reduced development time compared to C++ (not so much Python ;)) - generally, if you know what you're doing, you can be more productive in Java than in C++. I know C++ programmers who will dispute that, and that's why I qualify it with 'generally'. Java has a robust API that simplifies a lot of things for you, things that in C++ you would have to implement yourself or license a third party library for. And I have found that design implementation comes much more naturally when working for Java (but that's me, and others may disagree).


Agreed. The main thing is that the syntax has been greatly streamlined and simplified, and the language does OO-y things by default that you would have to ask for in C++ (in particular, virtual functions).

Quote:
* no pointers - yes, I see this as a pro! There are several common mistakes that can cause hard to find bugs in C and C++ when using pointers. Sometimes you don't even know of it until you release the app inton the wild (buffer overflows anyone?). But it's not a panacea, as you can still have NullPointerExceptions thrown when the user runs the app (which is equivalent to an access violation or segfault), and you can still have memory leaks (via dangling references).


Congratulations, you are sane. :)

Quote:
People who religiously defend one language over another generally can be ignored, as their opinions are horribly biased - and unfortunately you will find a lot of that here. I try to keep my opinions balanced, but I do favor Java over C++ so you can surely consider me biased.


ITYM people who religiously "support" or "promote" one language. Around here Java needs all the "defense" it can get ;)

Quote:
That's why I don't offer any opinions on C++ here (the cons list would be too long :)).


Wait, when did Lisp enter the discussion? :D

Share this post


Link to post
Share on other sites
Quote:
Original post by sykonet
I think Vampire: The Masquerade was done in java (if I recall correctly, it's been awhile.)

And the recent Battlefield 2 uses python for some stuff, such as stat exporting.

No, actually its running on Valve's Source engine, which is C++ using DirectX 8/9.

To the question at hand though: I use C++, simply because its the language that I know and have been using for the past few years. Would I ever attempt to use Java? Sure, but my school (and any school I'm going to be attending) teaches C++ as the main language. Java has its advantages, and is probably a little bit easier to learn than C++, but its not what the school is teaching (at least, here).

I believe Java has come leaps and bounds in its ability to be used for games, and I don't think it'll be long until you see it used in a lot of off the shelve products, especially when MAC OSX switches to Intel. You'll have as many developers as possible wanting to catch that bandwagon!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
[quote]Original post by Icefox
Quote:
*Dynamically typed... Yes yes, this can be a bad thing too, but not having to declare what types you're using when and how can save a lot of time, and make the program easier to read.


Statically typed languages like OCaml feature type inference. It isn't exclusive to dynamically typed languages.


Hope this helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zahlman
Quote:
Original post by Aldacron
People who religiously defend one language over another generally can be ignored, as their opinions are horribly biased - and unfortunately you will find a lot of that here. I try to keep my opinions balanced, but I do favor Java over C++ so you can surely consider me biased.


ITYM people who religiously "support" or "promote" one language. Around here Java needs all the "defense" it can get ;)


I second you on that!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this