Why not Java?

Luminary
Posts: 5,143
Joined: 2002.04
Post: #16
The JIT is free to make those optimizations, if it can prove that references to the object don't escape the function, and that they won't need garbage collection (eg. there are a fixed number of them).

Not, I think, that any do... but it's possible Smile
Quote this message in a reply
zKing
Unregistered
 
Post: #17
While I personally don't use Java for games, I've used it plenty for server side stuff and lately I've been using C#/.NET in my day job.

Java is pretty quick now a days.
- On garbage collection overhead: honestly most of the time the garbage collection only needs to run once... when the app closes. Why waste time deleting all over the darn place, when it doesn't need to be done? Kind of silly when 99% of the time a user has 300 MB free doing nothing. And if it runs out it will run when needed.

- On "lots of strings": This is one of those things that you deal with in Java (let's not pretend C++ doesn't have its nits.) If you build strings by concatenation "str1 + str2 + str3 ... " you are going to create a _slew_ of objects. Don't do it.

Honestly, my biggest nit with Java are the IDE's you have to deal with (excluding XCode here, sadly I don't have the luxury of developing only for Apple platforms.) I believe Carmack made the comment about Netbeans or Eclipse (same could be said of both): "When text editing on a 3.0Ghz machine is anything but instantaneous something is very deeply wrong."

Java is very cool on the server side due to its portability. But building little desktop apps, for example, is too much work, the IDE's are lame, the API's are a bit too involved and we all know about how the UI never _really_ works the same on every platform (Write Once Debug Everywhere) so portability isn't as good on the front end ... and really I'm just more productive in either C/C++ or (in Windows) C#.

And if I'm snuggling up to the hardware and twiddling bits, Java often actually makes more work for me than C/C++ due to a lack of pointers, lots of casting needed, lack of unsigned, etc.

But anyone who says you can't make a decent game in Java is stretching the truth more than a little bit. If you are productive in Java or even just really want to learn it, go for it.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #18
One thing I've done to keep java relatively fast ( right now I'm doing some side work doing image recognition ) is, when you have a loop that would create and destroy millions of simple objects which would be -- in C or C++ just a local struct -- you simple allocate that object outside the loop and re-use it.

I'm writing code which detects radially symmetrical objects ( cells, from a microscope ) and it hauls ass, mainly because during the analysis, there's only one call to new. I just re-use that memory.

To make Java fast, you have to understand it, and its limitations. The JVM can do numerical operations on primitives every bit as fast as C++, it's just the allocation and pauses for deallocation that suck up time.

Most people coming to Java write code like they did back when they were using C/C++ and make lots of struct type objects which are alocated and deleted willy nilly. That's the problem. Such operations are "free" in C/C++ but are incredibly expensive in Java.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #19
IMHO, the problem with Java is that it makes things easier to do, but it doesn't help a bit to do things better. So, most people, especially novice programmers, create an unimaginable mess because they don't have a clue about what is going on in the background. Sadly, implementation differences in the runtime environments can also spoil your soup, slowing things to a crawl on one platform but not the other. The runtime is too smart for its own good.

Also, I think Java encourages lazy programming in a bad way. It could have become a good language, but it's no dolt better than C++ overall. The Java frameworks are a good thing, they provide a nearly all-encompassing, portable API to the OS, unlike the UNIX/Mac/Win32 crap you have to face with C/C++. Though Java bytecode allows the same executable to run on different platforms, this is only an advantage in web applications. You can write C/C++ to be just as portable, but have to recompile for each platform. Not a big deal for me.
Quote this message in a reply
Nibbie
Posts: 2
Joined: 2008.02
Post: #20
"Works for me"

Using LWJGL and Java is a ton easier than anything else on the Mac. Except for BlitzMax.

Cas Smile
Quote this message in a reply
Member
Posts: 168
Joined: 2004.10
Post: #21
And Playkode. And Unity.
Quote this message in a reply
Member
Posts: 110
Joined: 2002.04
Post: #22
zKing Wrote:Honestly, my biggest nit with Java are the IDE's you have to deal with (excluding XCode here, sadly I don't have the luxury of developing only for Apple platforms.)

Have you tried http://www.eclipse.org/ for JAVA
I have many java programmers that swear by it and say it is a very advanced IDE
it all runs on all platforms being written in java.

- Mac Lead ZeniMax Online Studios
- Owner Plaid World Studios
- Resume: http://www.chrisdillman.com
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #23
ChrisD Wrote:Have you tried http://www.eclipse.org/ for JAVA
I have many java programmers that swear by it and say it is a very advanced IDE
it all runs on all platforms being written in java.

It has a lot of great features, but the UI is absolutely awful. (IMHO of course)

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Post Reply