Jump to content
  • Advertisement
Sign in to follow this  
usxue

[java] I want to know how much advantage about game development in java!

This topic is 4629 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to develop game in java but I must know how much advantage about game development in java! The game is PC game not j2me.

Share this post


Link to post
Share on other sites
Advertisement
What do you consider an advantage? And what kind of game is it? 2d? 3d? text?

Probably subjective, but what I'd consider some advantages are:
1) faster development time due to somewhat clearer syntax, an easily available and very extensive standard library (but this is true for c++ also, to some extent)
2) no messing about with pointers (everything is passed by value.. no, wait - everything is passed by reference.. no, wait..)
3) package namespace system makes dividing your work into modular components more intuitive
4) automatic garbage collection (but for some games this might be a bad thing - and you still need to take care of other types of garbage)
5) faster object instantiation times, it's generally cheaper to create java objects than c++ objects (or so they say)
6) no legacy language (ie, C) to support = clearer OO
7) easier to learn and get started with
8) easier web distribution (or not. Webstart is annoying, and otherwise you're restricting yourself to people who have or are willing to download the jre)

Share this post


Link to post
Share on other sites
Quote:
Original post by lightbringer
What do you consider an advantage? And what kind of game is it? 2d? 3d? text?

Probably subjective, but what I'd consider some advantages are:
1) faster development time due to somewhat clearer syntax, an easily available and very extensive standard library (but this is true for c++ also, to some extent)
2) no messing about with pointers (everything is passed by value.. no, wait -
..................


First of all, thanks for your reply. Thanks very much!
I have some consideration about your reply:
You consider the advantage from the language.
I want to know the advantage of the game development.
For instance, some problems in the game developed in C/C++ can be solved in java. And I also want to know the problems in the game developed in C/C++.

Thanks very much! :)

Share this post


Link to post
Share on other sites
I'm definitely not qualified to answer this question thoroughly, but I don't think there are as many differences as you think, with regards to game development. Both java and c++ are mature, object oriented languages, with a large standard library (java has the upper hand here - if you are starting from scratch and by yourself, you would definitely find the collections framework and the new concurrency utilities and the myriad of other java libraries to be helpful) and a wide possibility of applications. What kind of problems were you considering?

For instance, security considerations are mostly irrelevant - anyone who is determined enough will be able to decompile your product, regardless of whether it's obfuscated java object code or an executable compiled and linked with c++.

As mentioned before, the garbage collector does help with catching memory leaks which plague a lot of c++ games, but it can also be a bother - if you are creating too many objects per frame, the collector might slow down your program. Setting gc mode to incremental might alleviate the problem though, and I have no hard data on how many objects are "too many".

One thing that speaks strongly in favor of c++ is that a large number of game-specific libraries (for physics, networking, scene management, and collision detection) were written in c/c++. In comparison, java lacks such tools. We have some bindings for opengl, and a couple of scene graphs, and that's about it.

Share this post


Link to post
Share on other sites
I know Java and C++, and the difference isn't *that* big (compared to basic etc).

I like C++ more because it feels like I have more control over the pc, and it's easier to hack code :)). Also just the number&variety of libraries available are real nice.

However IMO coding java is more fun, it's cleaner, and goes faster (I also felt it was easier to debug, although this is quite dependant on what IDE etc you use). What i hate about java is that it's such a mission to get people to play your games, however, a game of mine ran absolutely fine on a mac (without me ever testing it on one!) which is not quite possible with c++. (Said game didn't run at all on linux, tho).

Basically, if you feel like making a small 2D game just for fun, I'd go with Java. If you want to make a bigger, distributable, possibly 3D game, I'd go with c++.

Share this post


Link to post
Share on other sites
I'd go with Java every time, because it's vastly easier, and the results are not really distinguishable.

Cas :)

Share this post


Link to post
Share on other sites
Quote:
Original post by lightbringer
1) faster development time due to somewhat clearer syntax, an easily available and very extensive standard library (but this is true for c++ also, to some extent)

The Java standard library is a mess. It looks like everyone at Sun worked on different parts and then they tried to throw it all together at the end. Also stuff gets changed with each version. In C++ you don't have to worry about which version of the language/API you have; if it compiles, you're good to go. With Java, you have to worry about which version of Java you are coding in and which your users will have.

Quote:
Original post by lightbringer
2) no messing about with pointers (everything is passed by value.. no, wait - everything is passed by reference.. no, wait..)

In C++, parameters are passed exactly as the programmer says they are. I don't see the problem with this. I thought no pointers was an advantage to Java until I got NullPointerExceptions. It's really not much better.

Quote:
Original post by lightbringer
3) package namespace system makes dividing your work into modular components more intuitive

C++ namespaces do this as well.

Quote:
Original post by lightbringer
4) automatic garbage collection (but for some games this might be a bad thing - and you still need to take care of other types of garbage)

This is a benefit when working on most types of software. On games, however, the gc will give you noticable performance hits. (I know there are ways to get around this, but you would be better off in a non-garbage collected language)

Quote:
Original post by lightbringer
5) faster object instantiation times, it's generally cheaper to create java objects than c++ objects (or so they say)

Yeah, I don't know where you got this idea, but it's not true. The time should be negligible in both, but if anything, C++ would be faster.

Quote:
Original post by lightbringer
6) no legacy language (ie, C) to support = clearer OO

Personally, I find the "Everything is an object" outlook very annoying, but this is a personal preference.

Quote:
Original post by lightbringer
7) easier to learn and get started with

This is a valid point.

Quote:
Original post by lightbringer
8) easier web distribution (or not. Webstart is annoying, and otherwise you're restricting yourself to people who have or are willing to download the jre)

Unless you are talking about applets, I don't see what you mean. I can put a C++ program on the web, and anybody can download and run it without problems (assuming they have the same OS).

Share this post


Link to post
Share on other sites
Everyone always forgets the fast turnaround time that Java gives you. <2 second compile times gives you lots of feedback when you're tweeking something or adding something in small pieces. Having to wait even a couple of minutes (and unless you're careful, it'll be much more than that) in C++ really interupts the flow and concentration.

Also, this has been answered in much detail about a bajillion times previously, have a search in the forum archives...

Share this post


Link to post
Share on other sites
Quote:
Original post by Simian Man
The Java standard library is a mess. It looks like everyone at Sun worked on different parts and then they tried to throw it all together at the end. Also stuff gets changed with each version. In C++ you don't have to worry about which version of the language/API you have; if it compiles, you're good to go. With Java, you have to worry about which version of Java you are coding in and which your users will have.


I disagree that the library is a mess. It's very useful. And Java is always backwards compatible, which is why some people complain it is a mess. The library has improved with each iteration, with Sun recommending to use the improved features in place of the older ones. Some improvements come in the area of performance (such as ArrayLists to replace Vectors), where as others come in the form of new method calls to replace older, inconsistent ones. I don't know anyone who worries about which version of Java to code to. The only decision one need make about versions is whether or not to use the very latest (which takes time to propagate through the market), or the last version (which has already propagated).

Quote:
In C++, parameters are passed exactly as the programmer says they are. I don't see the problem with this. I thought no pointers was an advantage to Java until I got NullPointerExceptions. It's really not much better.


In C++ is there isn't any protection from crashing the program on accessing a null pointer. And when you do get that sort of crash it can sometimes be difficult to find - particularly when they happen in the wild on not on your dev machines. NullPointerExceptions are not crashes, and they come with a detailed stack trace to help you pinpoint the exact location, even when they happen in the wild (unless you strip that info out of the class files). My current project is in C, a language with which I have a lot of experience. I know better, yet I still find myself hunting fixing crashes caused from null pointers more often than I would like. In Java, I almost never do. Seems benefit enough to me.

But even more importantly is that you don't have the security problems pointers bring to the table. How many times have you seen pointer-related security alerts for apps & libraries? And yes, even games (Unreal Tournament comes to mind). This is particularly important in networked games. Pointers are inherently unsafe and humans make mistakes. Java greatly reduces the chance that those mistakes will happen. Many companies implement their own schemes to prevent them anyway (such as detecting array bounds errors during development, but then they go and turn it off on release where they need it the most!). Safety and reduced development time aren't benefits?

Quote:
This is a benefit when working on most types of software. On games, however, the gc will give you noticable performance hits. (I know there are ways to get around this, but you would be better off in a non-garbage collected language)


This is such a myth. GCs, particularly in Java, have come a long way. You'll rarely find GC to be a problem even in games. If it is, it's most likely attributable to naive coding practices. Java has several tools to help with this, including different implementations of GCs to use. Besides, how many game developers implement their own custom memory managers, or smart pointer systems, to get a rudimentary GC going? Talk about saving development time.

Quote:
objects than c++ objects (or so they say)

Yeah, I don't know where you got this idea, but it's not true. The time should be negligible in both, but if anything, C++ would be faster.[/quote]

Memory allocation in garbage collected languages is almost always faster than in non-gced languages. Do some research via Google. This is one of the motivating factors behind garbage collection.

Quote:
Unless you are talking about applets, I don't see what you mean. I can put a C++ program on the web, and anybody can download and run it without problems (assuming they have the same OS).


Once the JRE is installed, Webstart is an easy distribution mechanism. The user always gets the most uptodate version of the app every time they run it. And it works across multiple platforms. Generally, the only thing you have to change for each platform is any native files you use - and it's easily configurable so that the user gets the appropriate files automatically.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!