Jump to content

  • Log In with Google      Sign In   
  • Create Account


Java is fast?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
111 replies to this topic

#101 arithma   Members   -  Reputation: 226

Like
0Likes
Like

Posted 19 April 2006 - 07:15 AM

What is the Java VM written on?
It is definately not created in Java.
Why is that?

Would they even consider running a Java VM on a Java VM?
Why is that?

Buttom line is: If your application does not have a game loop, Java just works out fine, even better than C++ in many aspects (speed of productivity...). Once there is an infinite loop, you'd better do the platform specific code yourself and let C++ run your horses.

My idea is to have a J to native code compiler. But there is already many of that: VC++ Compiler and Borland compiler.

But afterall, what do I know?

Sponsor:

#102 meisawesome   Members   -  Reputation: 186

Like
0Likes
Like

Posted 19 April 2006 - 07:32 AM

I think that java run by a VM would definately be slower than cpp. If the java code is JIT assembled, the speed should be close to cpp. Java might not be what you want to use to design cpu intensive physics engines, however if you are developing for multiple platforms or web based games such as runescape, then java is the way to go.

#103 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

0Likes

Posted 19 April 2006 - 08:16 AM

"A 32 bit integer is not an object :)
The overhead for the entire array is only 12 (or whatever) bytes."

I was talking about generic containers. Please show me how to make a generic container in java, that support primitive values without wrapping them.

#104 wfreliszka   Members   -  Reputation: 100

Like
0Likes
Like

Posted 19 April 2006 - 08:33 AM

-About StringBuffer in java: Indeed there is such class, but if you want to do anything with that you must convert it to string before use. Its because all methods are based on String method.


- java.lang.ExceptionInInitializerError
Why there is need for such exception in java????
Why is it thrown???? What here is developer dependend????


- People tell me: in future even doctor would write his own code for his operation robots. Sorry but I don't want them to do that. Rules of nature are rules of nature. Programmes should be written by experts not children. If child want to play in programmer ok. But dont tell C++ will die.
Java and C# are designed for market because there is small number of specialist in that area. Pople doesn't understand hardware. They even don't know why they study that....

My question is : Why these people should programm specialistic and diagnostic programmes???
Does not matter what is your game write in as long it is tetris or snake.

-Is it better that instead crushing application is hanging up and throwing exception??? If a consumer see exception will he be happier??? If something throws exception it should be closed. CLOSED. It is not working corectly so something that user will input might not be performed , saved. Sometimes something doesnt work and nowbody knows why. Its because people catch exceptions but do nothing. Is it better??????

-I recently installed plugin into my VS2003 NET. First he needed instaling J# runtime. It took hour to find and download it. Then plugin crushes. It just throw exception. What is stability of that??? Why sould I aks consumer to download something like that??? They should just click twice....

-Its my personal opinion: Don't put it enywhere. Its cool that there is no need for assembler for programming cheap cards, cool. Cool that you can put it on 5 6GHZ machines and will be running like on one written in C++. But use it on servers but no desktop and specialistic and oriented systems. When I see programm written in java I delete it. There is much more progtrammes written in c++ running fast. Consumer will buy only that one he checked. If he will be asked to stay for a 5 minutes longer he will turn to some other provider.



-If you need stability and java gives you it. Ok. But what about thousends of c++ programmes wrritten for industry? There are stable. Yours hauses use benefits of it always. Waste water threatment controling systems are c++ based. Your electricy supplyer uses only c++ based programmes. Aren't they stable???? For me java does not gives stability at all. Nowadays compilers (and here I meant Microsofts and Borlands compilers) gives you opportunity to check everything with debbuger. If your application running from such enviroment cruch they even tell you in wich line. Debbuger in java sucks. It does not wotrking correctly and checking values of table in debug mode takes sometimes 3 minutes where programm hangs. If you need GCC use GCC for release. Here in Poland I personally know some big foeign international companies that uses VC++6 for debug and gcc for release.

What about one of most stable system in the world - UNIX???? Where is java here????



-What about running multiple programms on the same VM instance???? They run as shit. As one process!!!!! And more important, your communistic collective of VM will fail in that case. I donk't know why it happens but some of classes that have the same name in both applets run incorectlly. What about


-Why should I send all object ( and make it something inherited first ) if I only need to send one byte flag???? Why everything is parsed to string first???

-Why everything is first converted to 32 bit??? Boolean is 32 bit-its nonsense. Using Short byte or char will convert it first to integer, and next do needed calculations and then go back to it oryginal shape. It drives me creazy that they put it into small devices and gives not 200GB of memory but only 200kb in some cases. All games written in java is shiet. In the begining 8-16 bit games were cooler and better then these writen for modern java. Cool animations etc. Look at PC 286 XT i AT. GAMES were COOL!!!!! Nowadeys small games is a piece of crap. It does not depend on developers. It depends on JAVA.


-C is more easier then Assembler. C++ adds objects and generics. What does java and NET gives more that is important???? GC????? In C++ there is such if you need. They only need special threating and nobody uses it for surious.
C++ is more object oriented developement powerfull enviroment then java.
Where is protected????
What about multiple inheritance????????


One more.
C++ will not be repleaced by java or c#.

It will be repleaced soon by new specification called C++0x9.




#105 Promit   Moderators   -  Reputation: 6341

Like
0Likes
Like

Posted 19 April 2006 - 08:54 AM

wfreliszka: Some of your gripes are java specific, but most are just incredibly ignorant and not at all well informed. You blame Java for bad coders, which makes no sense.

Java and C# provide high performance, but not necessarily maximum performance environments (except for Java GUIs, which suck) on PC. No, I wouldn't use them to develop on a console. I'd be very reluctant to choose them for the core of a next gen engine. But how many of you are working on bleeding edge technology? Hell, the people working on that level have better things to do than quibble here, and so I'd bet money that no one who has posted here is working on next gen games on X360/PS3, or PC for that matter. So you don't need absolute critically maximum performance (and I'd question how many of you even have the skill to do that kind of work).

#106 justo   Members   -  Reputation: 184

Like
0Likes
Like

Posted 19 April 2006 - 09:04 AM

agreed.

i'm doing "bleeding edge" stuff, some crazy gpgpu shenanigans in, get this, java! that's because i looked at my *specific needs*: i may be pushing the gpu to its limits, but the cpu is rather underutilized and i need a quick prototyping environment for the interface. imagine that, using different tools for different jobs.

i suggest this thread be closed or at least moved to the lounge; nothing remotely useful has or will come out of it.

#107 Fred304   Members   -  Reputation: 382

Like
0Likes
Like

Posted 19 April 2006 - 10:56 AM

Quote:
Original post by arithma
What is the Java VM written on?

You can write a Java VM in lots of languages. I believe the Sun VM is written in C or C++.

Quote:

It is definately not created in Java. Why is that?
Would they even consider running a Java VM on a Java VM?
Why is that?

Because it is impossible. That Java VM would need another VM and so on. Sweet honeybee of infinity.



Quote:
Original post by Anonymous Poster
Please show me how to make a generic container in java, that support primitive values without wrapping them.

Generics do not apply to primitive types. Either use an array or autoboxing.

I personally never had the need for a container that stores primitive types.



Quote:
Original post by wfreliszka
-About StringBuffer in java: Indeed there is such class, but if you want to do anything with that you must convert it to string before use. Its because all methods are based on String method.

So what?! If a method needs a String for input (for example: System.out.println), just call StringBuffer.toString() once. Do you really think this will be a bottleneck?

Quote:

- java.lang.ExceptionInInitializerError
Why there is need for such exception in java????
Why is it thrown????

Look at the API specifications:


public class ExceptionInInitializerError extends LinkageError

Signals that an unexpected exception has occurred in a static initializer. An ExceptionInInitializerError is thrown to indicate that an exception occurred during evaluation of a static initializer or the initializer for a static variable.

Quote:

What here is developer dependend????

I'm not following you...?

Quote:

- People tell me: in future even doctor would write his own code for his operation robots. Sorry but I don't want them to do that.

What does that have to do with Java?

Quote:

Java and C# are designed for market because there is small number of specialist in that area.

What market? What area?

Quote:

Pople doesn't understand hardware. They even don't know why they study that....

What are you talking about?

Quote:

-Is it better that instead crushing application is hanging up and throwing exception???

Yes, because this is called "defined behavior". In C/C++, it is possible to write out of bounds into an array and get away with it 99 times but failing the 100th time. With the mechanism of exceptions, you know exactly what went wrong.

Quote:

If a consumer see exception will he be happier???

Consumers are not supposed to see exceptions.

Unchecked exceptions are thrown when the programmer made a mistake (array index out of bounds, concurrent modification etc). Unchecked exceptions are very useful for debugging.

Checked exceptions are caught by the application. For example, the user tries to open a file which does not exist, or the user wants to send a message to a server without being connected to the internet. These exceptions are caught and reacted upon.

Quote:

Its because people catch exceptions but do nothing. Is it better??????

Nobody is supposed to catch an exception without handling it. This isn't java's fault or the fault of exceptions in general.

Quote:

-I recently installed plugin into my VS2003 NET. First he needed instaling J# runtime. It took hour to find and download it. Then plugin crushes. It just throw exception. What is stability of that??? Why sould I aks consumer to download something like that??? They should just click twice....

I never tried J#. BWT J# has nothing to do with java!

Quote:

There is much more progtrammes written in c++ running fast.

How much faster than java is C++? I'd really like to know. 10 times?

Quote:

But what about thousends of c++ programmes wrritten for industry? There are stable.

The point is: it is much more diffult to

a) write stable programs in C/C++
b) prove their correctness

Quote:

-Why should I send all object ( and make it something inherited first ) if I only need to send one byte flag???? Why everything is parsed to string first???

What are you talking about? what is parsed to string? What do you mean be "sending"?

Quote:

Boolean is 32 bit-its nonsense.

I believe the size of bool is up to the VM implementation (but I might be wrong).

Quote:

-C is more easier then Assembler. C++ adds objects and generics. What does java and NET gives more that is important?

Java is a lot simpler than C++. It prevents the user from shooting himself in the foot.

Java does not have pointers. Java does not have structs. Java does not have multiple inheritance. Objects cannot be created on the stack. There are no initializer lists. Goto does not exist.

People like you complain about this. But I think it's great! You can print java's syntax on three or maybe five pages. It is easy to master java as a language.

Quote:

C++ is more object oriented developement powerfull enviroment then java.

C++ is not object oriented, it's multi-paradigm language. Java is a lot cleaner OO wise.

Quote:

Where is protected????

Java knows public, private and protected and default.

Quote:

What about multiple inheritance????????

Java has multiple type inheritance. You can implement as many interfaces as you like. Multiple implementation inheritance is evil, and I personally NEVER had a need for it (not even in my five years of C++ programming where I could have used it).

If you think a design is more OO because of multiple implementation inheritance, please read up on design patterns.

Quote:

For me java does not gives stability at all. [...] Debbuger in java sucks.

When I see programm written in java I delete it. [...] All games written in java is shiet.

Nowadeys small games is a piece of crap. It does not depend on developers. It depends on JAVA.

My experience with java is that it gives great stability. And the eclipse debugger is just wonderful. You obviously really hate java a lot and I guess there's nothing I can do about it.

#108 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

0Likes

Posted 19 April 2006 - 01:21 PM

Quote:

What is the Java VM written on?

What has this got to do with anything discussed in here? Do you think Sun should dump the current VM that's been polished for 10 years - just for the sake of proving that "it can be done"?

Quote:

Please show me how to make a generic container in java, that support primitive values without wrapping them.

And what is the point you are trying to make here? First of all, if you find yourself constantly needing primitive collections everywhere, chances are you are either doing premature optimizations or you're just a lousy Java programmer. Secondly, when you do need a one, you're doing an optimization - which can easily get very dirty anyways, and I kind of fail to see where the benefit of genericity kicks in ...?

Last time I needed a one, it took me less than two minutes to google for implementation of IntHashMap/FloatHashMap and about 5 seconds to replace Java's HashMap with the primitive one.


#109 DrGUI   Members   -  Reputation: 402

Like
0Likes
Like

Posted 23 April 2006 - 04:56 AM

Quote:
Original post by Anonymous Poster
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

Yep that's like when you implement IDisposable then use the 'using' keyword (or 'Using' in VB).

Though the limitation you mentioned _was_ tricky when doing object pooling in my image processing library. Wanting to recycle render target textures I use a 'using {}' block and in Dispose of my Image, its Buffer is returned to the pool for reuse. But if some silly person forgets, then that's 3 render targets created every frame until the finalizer kicks in (!), though I'm sure that someone would be greeted by an 'Out of video memory' exception pretty quick!

#110 DrGUI   Members   -  Reputation: 402

Like
0Likes
Like

Posted 23 April 2006 - 05:15 AM

Quote:

Java has multiple type inheritance. You can implement as many interfaces as you like. Multiple implementation inheritance is evil, and I personally NEVER had a need for it (not even in my five years of C++ programming where I could have used it).

If you think a design is more OO because of multiple implementation inheritance, please read up on design patterns.

I agree heartily...my design book, Design Patterns Explained, taught me to always prefer aggregation over inheritance - great advice as I used to have long inheritance chains. It's a fantastic book - you should really check it out [smile]

#111 Fred304   Members   -  Reputation: 382

Like
0Likes
Like

Posted 02 May 2006 - 09:29 AM

Is it normal that a method takes like 20 times as long to execute the first time compared to later times? Is this were JIT takes place? Just curious :)

My profilings:

reordering took 1003000 ns
reordering took 51000 ns
reordering took 59000 ns
reordering took 62000 ns
reordering took 74000 ns

The first "reordering" that was done was even the most trivial among all those (only 3 elements to reorder).

EDIT: It gets even better. There seems to be a second optimization phase after which the speed triples:


reordering took 1075000 ns // first run
reordering took 54000 ns
reordering took 64000 ns
reordering took 70000 ns
reordering took 92000 ns
reordering took 89000 ns
reordering took 90000 ns
reordering took 139000 ns
reordering took 109000 ns
reordering took 103000 ns
reordering took 93000 ns
reordering took 93000 ns
reordering took 1872000 ns // 2nd optimization?
reordering took 26000 ns
reordering took 24000 ns
reordering took 24000 ns
reordering took 25000 ns
reordering took 28000 ns
reordering took 25000 ns
reordering took 23000 ns


#112 rip-off   Moderators   -  Reputation: 8068

Like
0Likes
Like

Posted 02 May 2006 - 09:41 AM

Quote:
Original post by Fred304
Is it normal that a method takes like 20 times as long to execute the first time compared to later times? Is this were JIT takes place? Just curious :)


Yes.

From what I've heard the Java VM will compile the code just before the first execution, and will optimize it the more heavily it is being used.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS