Java is fast?
April 17, 2006 03:21 PM
rip-off: What are you talking about? How would normal stack usage make an app a memory hog? (The default stack size in most compilers is 1MB or something.) And the stack isnt for storing dynamic arrays, if you believe that, then you clearly dont know what its useful for.
Quote: Original post by Anonymous Poster
rip-off: What are you talking about? How would normal stack usage make an app a memory hog? (The default stack size in most compilers is 1MB or something.) And the stack isnt for storing dynamic arrays, if you believe that, then you clearly dont know what its useful for.
I think what he meant was that if you replaced dynamic memory allocation with static memory allocations your program's memory usage would ballon up. Consider loading a bitmap, say it takes 1 meg of memory to load and you know this at compile time.
By using dynamic memory allocation your program only uses(allocates) that meg if its used. But if you put it on the stack then your program allocates that meg( by loading the code) even if the bitmap isn't loaded.
Does that help explain it??
Cheers
Chris
CheersChris
Quote: Original post by esuvs
If I create in in C/C++, however, then it can be used by everybody via easy to create language bindings. As a developer I maximise the number of people who will make use of my product and therefore maximise my profit.
From this perspective C/C++ give the greatest flexibility.
Right on. With your source I could create JNI calls.
I am still amazed that the 'speed' debate between java and C/C++ still rears it's ugly head from time to time. Being a java fanboy as some of you might call it (my main language of use), I personally don't give a poop which one is faster. I just use what gets the job done and has decent performance (Im not writing bleeding edge engine code). If I were to write a complex math/scientific application I would definitely consider using Fortran to write the calculation engine!
I do agree with much of what everyone here has to say...
Java is generally slower: Yes.
Benchmarks are generally biased: Generally agree.
Studios have invested millions into their tools/libs etc... they are not going to convert overnight: true^2
Jake2 is impressive, but not 'OMFG that is freakin groundbreaking'.
This argument is pointless because languages evolve rather quickly: good point.
My last two cents on the matter.
Use Java if you think it will get the job done to your satisfaction. It never hurts to learn or refresh your Java language skills (fanboy plug).
If you are looking at a job in the gaming/vis_sim industry, or are looking to write your own bleeding edge graphics code... use C++/C/ASM.
On a final note.
It's sucks java can not reference member functions! I miss function pointers.
Ok rate the fan boy down now ;)
∫Mc
On the subject of finalizers...
I believe destructors are used in C++ to delete memory allocations. However, with the GC this is not needed because it cleans up managed objects. For unmanaged objects like native operating system handles, you implement System.IDisposable and create a finalizer which releases your unmanaged resources.
They said using the same destructor syntax for finalizers was misleading...
I believe destructors are used in C++ to delete memory allocations. However, with the GC this is not needed because it cleans up managed objects. For unmanaged objects like native operating system handles, you implement System.IDisposable and create a finalizer which releases your unmanaged resources.
They said using the same destructor syntax for finalizers was misleading...
------------------------------------Development of Rock, Paper, Scissors - The Third Dimension
April 18, 2006 08:30 AM
The good thing with destructors in C++ is that they are guaranteed to be run when the object goes out of scope/is deleted using delete. This way you can use RAII:
http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
Hi
I am at 4th year of Computer Science in Poland. On my year there are only 3 persons including me from 150 that known and understand c++.
-People think that c++ hasn't got classes (its reserved only for "new generation" langages). They even think basing on small lessons of C from 1st year that there are no threads...
Everybody use java or C#.
How is here????
There are thousands of things for me that in java are unefficient and makes me laugh.
Some of them:
1. How many time will take chanching 20th character of that string:
String mystring="How do you want to do that?";
???????????????????????????
2. What will happen if the string will be 4000 bytes long and you will have to change that one character???
Answer: create and copy byte table of 4000 items. Build String from begining with new table. Discarding old one.
3. What will hapen if you just take value of a one byte from string?????
int z=x.getByte(y);
What will be z???? Unsigned unicode. Even if string is encoded.
hmmm. Isn't byte range in java -127 - 128??????
Next. Please return byte table from string. Isnt it in single byte per one char format??? Why get bytes return non unicode while getting one byte gets unicode????
I saw comparation of oryginal quake 2 and these rewritten in java. Speed on 3200 GHZ with strong gforce card shows only 2 time difference, however what will be difference on pentium 100mhz???
I worked with java - j2ee ejb and j2me for a long time and many things are easier, however thousands of things weren't so easy and I could even say very difficoult to do with java or sometimes impossible. Up to now in java I builded 4 games in j2me and any time I done some of it I just thought : "If I only been writting in c++".... Things written in Symbian C++ without opengl es (using owns implementation of 3d engine) are going faster and better then these written in java using opengl es in the same machine. Now I stick to C++....
How could you compare it??
Regards
Wojtek F
I am at 4th year of Computer Science in Poland. On my year there are only 3 persons including me from 150 that known and understand c++.
-People think that c++ hasn't got classes (its reserved only for "new generation" langages). They even think basing on small lessons of C from 1st year that there are no threads...
Everybody use java or C#.
How is here????
There are thousands of things for me that in java are unefficient and makes me laugh.
Some of them:
1. How many time will take chanching 20th character of that string:
String mystring="How do you want to do that?";
???????????????????????????
2. What will happen if the string will be 4000 bytes long and you will have to change that one character???
Answer: create and copy byte table of 4000 items. Build String from begining with new table. Discarding old one.
3. What will hapen if you just take value of a one byte from string?????
int z=x.getByte(y);
What will be z???? Unsigned unicode. Even if string is encoded.
hmmm. Isn't byte range in java -127 - 128??????
Next. Please return byte table from string. Isnt it in single byte per one char format??? Why get bytes return non unicode while getting one byte gets unicode????
I saw comparation of oryginal quake 2 and these rewritten in java. Speed on 3200 GHZ with strong gforce card shows only 2 time difference, however what will be difference on pentium 100mhz???
I worked with java - j2ee ejb and j2me for a long time and many things are easier, however thousands of things weren't so easy and I could even say very difficoult to do with java or sometimes impossible. Up to now in java I builded 4 games in j2me and any time I done some of it I just thought : "If I only been writting in c++".... Things written in Symbian C++ without opengl es (using owns implementation of 3d engine) are going faster and better then these written in java using opengl es in the same machine. Now I stick to C++....
How could you compare it??
Regards
Wojtek F
Quote: Original post by wfreliszka
1. How many time will take chanching 20th character of that string:
String mystring="How do you want to do that?";
???????????????????????????
It's actually very easy if you use the right tools. Strings are immutable in Java, so there's no way to change them. Use StringBuffers instead:
StringBuffer mystring = new StringBuffer("How do you want to do that?");mystring.setCharAt(20, 'x');
Quote:
2. What will happen if the string will be 4000 bytes long and you will have to change that one character???
Answer: create and copy byte table of 4000 items. Build String from begining with new table. Discarding old one.
Wrong answer! Use StringBuffer.
Quote:
3. What will hapen if you just take value of a one byte from string?????
int z=x.getByte(y);
There's no getByte() method defined for String...? This is how I would do it:
char c = charAt(int position);
Quote:
Please return byte table from string.
Why do you even want to do that?
I personally do not care if C++ is faster than java. Java is fast enough for me.
April 18, 2006 12:52 PM
Quote: Original post by wfreliszka
I saw comparation of oryginal quake 2 and these rewritten in java. Speed on 3200 GHZ with strong gforce card shows only 2 time difference, however what will be difference on pentium 100mhz???
Why would anyone care what the performance is on pentium 100mhz ?????
And as the Jake2 tests were ran with Geforce4 in low res you can safely ignore the GPU altogether and just compare the CPU performance, so it's a pretty ideal benchmark - for what it's worth anyway.
I'm not sure how you could've possibly miss something like StringBuffer/StringBuilder as you said you did lots of J2EE/J2ME. And judging the performance of Java by J2ME is simply ridiculous.
I always find it amazing how many people whine about the irrelevant flaws and some badly designed legacy classes in JAva (that are now stuck because of backwards compatibility) and in many cases completely ignore the strong points due to these minor annoyances. That's really not very professional.
April 18, 2006 02:17 PM
The C version of Quake 2 handles the triangles on a per-tri level by the CPU, so its not a fair comparison. Java programmers seems to lack insight when it comes to real benchmarking (look at all the stupid microbenchmarks on java programming sites).
By the 100mhz comment, wfreliszka probably meant that it is closer to the target machine for quake 2 ( ~200mhz or something, no GPU ), on machines like that, the port would run like shit ;)
And please, no stupid comments about how performance doesnt matter, it _does_ matter if you want to do cutting edge things.
By the 100mhz comment, wfreliszka probably meant that it is closer to the target machine for quake 2 ( ~200mhz or something, no GPU ), on machines like that, the port would run like shit ;)
And please, no stupid comments about how performance doesnt matter, it _does_ matter if you want to do cutting edge things.
Speed. Speed. Speed.
*looks at the number of buggy games and released patches for the PC*
I don't think anyone here would argue that C#/Java are easier to work in and help to prevent programmer error by limiting what they can do - the hard core programmers want the control that C++ gives them. Me? I have no need of it.
Having a fast game is worthless if it crashes all the time. I think the games industry needs to wake up and smell the coffee. Speed is good. Reliability and stability is better.
(At least to me.)
*looks at the number of buggy games and released patches for the PC*
I don't think anyone here would argue that C#/Java are easier to work in and help to prevent programmer error by limiting what they can do - the hard core programmers want the control that C++ gives them. Me? I have no need of it.
Having a fast game is worthless if it crashes all the time. I think the games industry needs to wake up and smell the coffee. Speed is good. Reliability and stability is better.
(At least to me.)
..what we do will echo throughout eternity..
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement