Skip to main content
gamedev.net
🔒 Locked

[java] programming language

Started by dennis_liew Mar 27, 2009 at 2:44 AM 13 replies 2.4k views
Original Post
dennis_liew
dennis_liew
after 2 day journey in this community i found that there were lots of people dont like Java. Is that java was too complecated and can be replace by other language?
GuyWithBeard
GuyWithBeard
I actually think there are a lot of people on this forum that likes Java. It is a mature and modern language and it runs on everything (including the kitchen sink). The main problem with Java in game development is that it is significantly slower than e.g. C or C++, since it compiles to byte code instead of assembly.

However, there is nothing stopping you from using Java if you like. It is much simpler and easier to learn than C or C++. Another great alternative is C#, but that basically forces you to develop on windows.
Mike nl
Mike nl
Quote:
Original post by GuyWithBeard
The main problem with Java in game development is that it is significantly slower than e.g. C or C++, since it compiles to byte code instead of assembly.

I find it hard to use this argument to justify natively compiled languages over VM languages since I always consider the case that the VM might be able to do runtime optimizations that natively compiled code can't, such as detecting situations (loops, calls) that can be significantly improved.

I don't know enough about the different Java VMs to be able to say with a clear conscience that Java is worse than C++ across the board (though I have a feeling it is...). Therefore I tend to stay out of Java-vs-C++ debates [smile]
Million-to-one chances occur nine times out of ten!
GuyWithBeard
GuyWithBeard
You are probably right. It was not my intention to start (yet another) debate over which langauge is better. I just tried to explain why a lot of people might choose a compiled language over Java.
BitMaster
BitMaster
Claiming that Java is "significantly slower" than C/C++ and then suggesting C# instead is false on so many levels.

Both Java and C# compile to byte code which would be on the slow side to execute by naive means. Only neither is executed as byte code since very well working JIT compilers are used to run both nowadays which remove most of the performance penalty compared to real native code for both.
Actually you can force scenarios where JIT compiled code will be faster since a JIT compiler can make decisions at runtime which a static C/C++ could not make at compile time. However, in general either of Java or C# will be slower (definitely not significantly though unless the writer writes messy code) than native code. Opposed to that are other advantages Java or C# have over C/C++ which once again just reinforces the axiom that you should think about what you need and then pick the right tool for the job.

Additionally, C# does not force you to develop on Windows. My experience with that language is limited, but last I checked Mono was a very reasonable implementation on Linux.
elFarto
elFarto
Quote:
Original post by Mike nl
Quote:
Original post by GuyWithBeard
The main problem with Java in game development is that it is significantly slower than e.g. C or C++, since it compiles to byte code instead of assembly.

I find it hard to use this argument to justify natively compiled languages over VM languages since I always consider the case that the VM might be able to do runtime optimizations that natively compiled code can't, such as detecting situations (loops, calls) that can be significantly improved.

I don't know enough about the different Java VMs to be able to say with a clear conscience that Java is worse than C++ across the board (though I have a feeling it is...). Therefore I tend to stay out of Java-vs-C++ debates [smile]

While I am firmly in the Pro-Java camp, when it comes to game development, Java lacks support for SIMD instructions so it is not as fast as something that does have access to them.

I've actually looked into implementing a vec4 directly into the VM. For the most part it's quite straight forward, however one of the limits Java has is available bytecodes. There are only about 20-30 left (I can't remember the exact number off the top of my head). This means you need to implement some sort of selector bytecode and it starts getting messy after that due to some design choices in the VM.

But for the most part Java is on a level with C/C++ for performance, if you give the VM enough time to work it's magic. In terms of development time, Java does have an advantage over C/C++ due to no memory management issues and a large standard library.

One more thing, the is really no 'interpreted' mode in the Sun JVM. The lowest level it has for running code is a macro assembler, which basically means it has a small snippet of assembly code for each Java bytecode which it assembles for each method, then runs it. So it is always native code that is run, it's just doesn't have any optimisations done.

Regards
elFarto
Ezbez
Ezbez
There's been a million and two threads on this. Search for 'em.

And no, people here don't hate Java. If anything, there's slight resentment against C++, if only because it tends to generate all those "X vs. C++" discussions which devolve into "But C++ is used by the pros and is super awesomely fast!"

I get the impression that you know or are currently learning Java. If so, stick with it and make your games there until you feel like learning a new language (it's always better to know more languages).
GuyWithBeard
GuyWithBeard
Quote:
Original post by BitMaster
Claiming that Java is "significantly slower" than C/C++ and then suggesting C# instead is false on so many levels.


I am perfectly aware that C# is compiled into CIL, not native code. I just gave C# as an alternative to Java, in case the OP wanted something simpler. And while Mono is available (I have used it myself on the Mac) 95% of the C# coders use Windows. And many gaming libs for .NET only work on the official .NET Framework.
Xyle
Xyle
I really dont think newbs like me will be confronted with runs slower than x because x runs native... etc. In my opinion, the only time this becomes a real factor is when you have created an awesome cpu, gpu intensive game that requires all of the optimizations and memory it can grab. Most of us newb devs couldnt put a strain on a system if we had to, and if we did it would be due to inappropriate coding structure and wrongful application of theories and not due to which language we used.


I think for people that ask about any language and opinions, its more important to stick with what makes you comfortable or if brand new to programming start with the easiest language to learn and work up from there.

I will say this, at this time Java fits my needs which mainly concentrate on deployment, but as this newb envisions new adventures, that may change down the road. I enthusiastically jumped into Java from Basic due to, in my mind, a simple progression.

To me, it would be better to recommend langauges based on ease of learning and the symmetrical steps of more demanding games or systems.
Basic
Visual Basic
Blitz Basic or Dark Basic
Java or C#
C++ (The main reason I would learn this is to get into the main stream AAA title game developement business as a career)

Of course these languages are based on my own personal experience and as such are a bit biased.
Cornstalks
Cornstalks
Quote:
Original post by dennis_liew
after 2 day journey in this community i found that there were lots of people dont like Java. Is that java was too complecated and can be replace by other language?
I like Java. It's a good language. But I hate doing graphical work in Java. It feels clumsy, and so much is asynchronous that getting certain results can be difficult.

Quote:
Original post by Xyle
I really dont think newbs like me will be confronted with runs slower than x because x runs native... etc. In my opinion, the only time this becomes a real factor is when you have created an awesome cpu, gpu intensive game that requires all of the optimizations and memory it can grab. Most of us newb devs couldnt put a strain on a system if we had to, and if we did it would be due to inappropriate coding structure and wrongful application of theories and not due to which language we used.
I totally agree, but to be honest, a n00b doesn't understand what may or may not be time constraining on a computer. This lack of understanding can easily lead to the mind set that everything must always run as fast as it possibly can, which may cause a user to start using poor code quality or dive into languages/paradigms that are way above them. Though I guess it's just part of the learning process [smile]
Fruny
Fruny
Quote:
Original post by dennis_liew
after 2 day journey in this community i found that there were lots of people dont like Java. Is that java was too complecated and can be replace by other language?


I just don't like the language itself. It's not a question of complication but rather a matter of personal taste. I dislike a number of design decisions that have been made both at the language and the library level, though I will admit I haven't looked at it much in the past 6 to 7 years.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
ninten
ninten
Hi!

Java can sometimes go faster than C++ (see Jake2 for example), sometimes slower. Therefore, please stop saying stupid things about it. If your Java game is slow, maybe it is your fault, maybe it comes from your way of programming, your algorithms, etc... The algorithmic choices have more weight than the choice of the language. When you use Java with OpenGL, you get comparable frame rates than those with C++/GLUT/OpenGL.
http://tuer.sourceforge.net/tuer.jnlp (game installation)http://tuer.sourceforge.net/experimental/tuer.jnlp (experimental version)http://tuer.sourceforge.net/download.php (source code)
pp000
pp000
I dont think that java can be faster than c++. Jake2 isnt fast because of using Java, it's fast because of good optimization. But as long as you are not using 10,000+ particles or huge landscapes in your app, java will do his job as a game programming language.
ninten
ninten
It is wrong. Java can be 15% faster than C/C++ (not always) because it uses both some dynamic optimizations that cannot be used in purely compiled languages and lots of static optimizations that are already used in compiled languages, the both of the best paths as Java is not purely interpreted, it is pre-compiled into bytecodes and binary codes (see JIT) and then interpreted.

Instead of saying prejudices, you should read about "Current State of Java for HPC", it shows Java can be faster than Fortran (but there are still some tiny problems of scalability). Open your mind.

This is a small example of a game written with JME 2.0 (no sound sorry):
http://tuer.sourceforge.net/tuer.jnlp (game installation)http://tuer.sourceforge.net/experimental/tuer.jnlp (experimental version)http://tuer.sourceforge.net/download.php (source code)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.