RPGDXThe center of Indie-RPG gaming
Not logged in. [log in] [register]
 
 
Post new topic Reply to topic Goto page Previous  1, 2 
View previous topic - View next topic  
Author Message
LeoDraco
Demon Hunter


Joined: 24 Jun 2003
Posts: 584
Location: Riverside, South Cali

PostPosted: Sun Apr 18, 2004 8:43 pm    Post subject: Re: Question regarding Java [quote]

Rainer Deyke wrote:
2. Because C is so close to the metal, the compiler isn't expected to perform a lot of high level optimizations.


There are compiler optimization flags that the user can force the compiler to use. I did a bit of a study on different sorting routines on arrays written in C++, with different forms of inlined functions, with compiler optimizations either turned on to a specific level, or off.

Generally, optimization is something that isn't done to a great extent; most of the time spent in the compiler is actually done in the optimization phase, whereas everything else is generally quite speedy. You could, theoretically, allow a compiler to sit for a month, optimizing code for the system it is compiling for. Nobody really does that, but you could.
_________________
"...LeoDraco is a pompus git..." -- Mandrake
Back to top  
BigManJones
Scholar


Joined: 22 Mar 2003
Posts: 196

PostPosted: Sun Apr 18, 2004 9:34 pm    Post subject: [quote]

The difference is that the Sun JIT vm optimizes the code while its running. Because of this both c# and java can be faster than natively compiled c/c++:

http://www.osnews.com/story.php?news_id=5602&page=3

There are ALOT of gfx libs for java:

2D:

Java2d - this is FAST nowadays
GAGE2D
J2DA

3D:

lwjgl
jogl
xith-high level scenegraph; games specific
java3d - a high level scenegraph

Sound:

Java sound api
JOAL - open audio lib wrapper

Input:

JInput - gaming specific input api; wraps dircect input under winodows.

Physics:

Jode - open dynamics engine

Goto www.javagaming.org for more info.

[Whew! Thank God I was here to save you guys from ignorance!]
Back to top  
Bjorn
Demon Hunter


Joined: 29 May 2002
Posts: 1425
Location: Germany

PostPosted: Sun Apr 18, 2004 10:49 pm    Post subject: [quote]

Rainer Deyke wrote:
Bjørn wrote:
The advantage is really in portability, not in speed. If the advantage was speed too, why the heck are we still programming C/C++?

Because C++ is just as portable and a more powerful and elegant language.

I wasn't seriously asking, I know there are good reasons and I am using C++ myself too. Wether C++ is more powerful and elegant would just be your opinion, but C++ is certainly not just as portable as Java. There are slight annoying differences in C++ compilers and even bigger differences in the standard library, which also isn't even close to the huge Java standard library which behaves basically the same on every platform. Whatever is possible with portable C++ libraries and after installing abstraction libraries like SDL, wxWidgets or GLUT, it's not even close to how portable your Java program is. Porting a C++ program requires a lot more work most of the time, and you'd have to be very concious about how you write your code and which functions you use.
Back to top  
Rainer Deyke
Demon Hunter


Joined: 05 Jun 2002
Posts: 672

PostPosted: Mon Apr 19, 2004 12:49 am    Post subject: Re: Question regarding Java [quote]

LeoDraco wrote:
You could, theoretically, allow a compiler to sit for a month, optimizing code for the system it is compiling for. Nobody really does that, but you could.


You could if you had a compiler that supported that level of optimization. I'm not familiar with any such compilers. If I had the option, I would gladly sacrifice at least a couple of hours of compile time for a bit of additional runtime performance (for release builds only).
Back to top  
Rainer Deyke
Demon Hunter


Joined: 05 Jun 2002
Posts: 672

PostPosted: Mon Apr 19, 2004 1:11 am    Post subject: [quote]

Bjørn wrote:
I wasn't seriously asking, I know there are good reasons and I am using C++ myself too.


I assumed the question was rhetorical, but thought it deserved an answer anyway. Many people on both sides of the Java debate are only talking about speed, but I don't think this is really the main issue.

Quote:
Wether C++ is more powerful and elegant would just be your opinion, but C++ is certainly not just as portable as Java. There are slight annoying differences in C++ compilers and even bigger differences in the standard library, which also isn't even close to the huge Java standard library which behaves basically the same on every platform. Whatever is possible with portable C++ libraries and after installing abstraction libraries like SDL, wxWidgets or GLUT, it's not even close to how portable your Java program is.


The C++ standard library is small, but C++ has a greater selection of cross-platform third party libraries.

Granted, there are a lot of non-conformant C++ compilers. However, Java compatibility is not as easy as you make it sound. Not only do you have to deal with JVM bugs and library bugs, but you also have to deal with different versions of Java. It is enough if a C++ program can be compiled by at least one compiler per platform. A Java program is expected to run on any and all JVMs.

Quote:
Porting a C++ program requires a lot more work most of the time, and you'd have to be very concious about how you write your code and which functions you use.


When porting my own game Zynx to Linux, I only encountered two issues:

1. A very minor bug in my code prevented it from compiling on gcc. This only took a minute to fix.

2. A capitalization bug prevented the program from compiling on case sensitive file systems. Also only took a minute to fix, and using Java wouldn't have helped.
Back to top  
Bjorn
Demon Hunter


Joined: 29 May 2002
Posts: 1425
Location: Germany

PostPosted: Mon Apr 19, 2004 8:45 pm    Post subject: [quote]

Sure, it can be painless. My RPG engine, which had worked in Windows before but was further developed in Linux, wasn't easy to get working in Windows again. First we had some issues getting MinGW, MSYS, Allegro, Lua and libxml2 installed and even when it compiled, there were two memory bugs in my code that hadn't shown up in Linux but were causing consistent non-backtraceable crashes in Windows. It took a good few hours to get it to work. Had my RPG engine been using Java, the only thing required would be installing the JVM, and plop, it runs.

Maybe there are examples of the Java case where because of JVM bugs or different Java versions, it would be more troublesome too. But I'm pretty sure this is much less an issue than the C++ case. If it wasn't, the JVM looses its whole point of existance in my opinion.
Back to top  
I am Har har har
Slightly Deformed Faerie Princess


Joined: 08 Jan 2004
Posts: 33
Location: America.

PostPosted: Wed Apr 21, 2004 6:32 pm    Post subject: [quote]

Wait, wait,wait...I'm wanting to use Java as a compiled language like C or C++, not like a script language through a virtual machine. Are you telling me that I won't be able to do that?
_________________
I do what I like. Do you have a problem with that?
Back to top  
Bjorn
Demon Hunter


Joined: 29 May 2002
Posts: 1425
Location: Germany

PostPosted: Thu Apr 22, 2004 12:14 am    Post subject: [quote]

Uh, there's GCJ (GNU Compiler for Java) in development that can do that. It doesn't have, and will probably never have, complete standard library support though. Not sure if there's any other projects like that.
Back to top  
BigManJones
Scholar


Joined: 22 Mar 2003
Posts: 196

PostPosted: Thu Apr 22, 2004 11:59 pm    Post subject: [quote]

Quote:
Maybe there are examples of the Java case where because of JVM bugs or different Java versions, it would be more troublesome too.


The main problem with portability and Java is sometimes Apple jvm implementor lag behind. For example in jre 1.4.2 there is NO hardware accelerated gfx and no full screen support so even if your game runs at 150 fps in windows it will likely crawl in Mac OSX


I am Har har har wrote:
Wait, wait,wait...I'm wanting to use Java as a compiled language like C or C++, not like a script language through a virtual machine. Are you telling me that I won't be able to do that?


Hello? How do you think Java achieves cross platform support? What do you think Java is? Java executes through a virtual machine (like MS copied with c#/cli). Thats how it optimizes the code while it runs.

True you can use gcj to compile a .exe but AWT is not supported, so you will need to use a jni lib like lwjgl (which it was designed for btw).
Back to top  
Ninkazu
Demon Hunter


Joined: 08 Aug 2002
Posts: 945
Location: Location:

PostPosted: Fri Apr 23, 2004 12:15 am    Post subject: [quote]

Quote:
True you can use gcj to compile a .exe but AWT is not supported, so you will need to use a jni lib like lwjgl (which it was designed for btw).

This is the nerdiest sentence I've ever fuckin read in my entire life.
Back to top  
Post new topic Reply to topic Page 2 of 2 All times are GMT
Goto page Previous  1, 2 



Display posts from previous:   
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum