Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


[java] Java and performance


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
15 replies to this topic

#1 Fovster   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 November 2000 - 04:39 AM

Hola. I''ve been reading these forums for some time already and finally decided to participate. I have been planning out an isometric type of game in java, and have come up with some questions considering the fact that java as itself is a little slower than many alternatives. So, for not getting too excited and megalomaniac, I was wondering if it''s possible to code _large_ games in java, with _decent_ graphics and things like that? Or are there some straight restrictions that would make this impossible? I''ve seen many nice little java games, but no larger ones, that would have more to play than a few little levels like in pacman or some small car-racing game? Second, I was wondering (IF I can ever get to there, or if its not too much asked) about a situation, in which I have walls on my map, and a player moves behind them. I''d like the walls that the player is behind to become partially transparent. In this case I think I can''t avoid using PixelGrabber and MemoryImageSource to alter the alpha-values of the pixels? Same thing if I would like the tiles to have some dynamic lighting around the player; each time the player moves, I''d have to go through the tiles that would be affected by altering the color values of the pixels? Using PixelGrabber and MemoryImageSource in things like this would be very slow (?), and I couldn''t think of any faster alternatives, anyone have any? In the wall case, I could of course make transparent duplicates of the non-transparent ones, but i don''t think i could do it on each tile PS. Any tutorials or such would be very welcome, though i think i''ve gone through the most.. Thanks in advance. ''''2+2=5 for extremely large values of 2.''''

Sponsor:

#2 felonius   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 November 2000 - 06:11 AM

First, welcome Fovster.

It is possible to write large games in Java, but at the moment it is unrealistic to write them in 100% pure Java. 100% pure Java has a number of limitations that makes it unsuitable for commercial-class games. However, there are nothing preventing you from mixing Java with C++ and getting the best from both worlds.

The electronic arts game "Prax War" did this with success but was unfortunately cancelled before completion because it "slipped its technology window". This happens sometimes ad had nothing to do with using Java - in fact the developers was happy doing so.

Vampire - The Masquarade uses Java as its scripting engine, meaning that much control code is made in Java while the rest is in C++.

Also take a look at the forum FAQ. And read the article at www.gamasutra.com about Dirty Java. (you can find it under features)

I have written an article about these things here: (the server is down at the moment but I hope my ISP gets it up again shortly):
http://www.rolemaker.dk/articles/WhyJavaCanBeUsedForGames/index.htm

I am currently using this methodology to write a 3D CRPG authoring system (www.rolemaker.com) and are getting pretty good frame rates in 3D using a Quake II like engine.

And as for PixelGrabber and MemoryImageSource - those are good for applets or small games, but for large games; forget it. Use something more powerful that is available on your machine (directX or OpenGL or something like that).

I hope this has enlightened you.

Jacob Marner

#3 snowmoon   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 November 2000 - 06:55 AM

Favster,

It all depends on how large a game you are talking about. I am working on a side scroller typ eof game and have been probing at the graphics performance thing. Here are some rough unauduted numbers from sun jdk 1.3..

640x480 drawing 2400 16x16 tiles randomly on the screen.

With a basic offscreen & tile w/alpha 10fps
With a basic offscreen & non transparent tiles 15fps
With an offscreen MemoryImageSource & copyarray to blit tiles 33fps

This is just testing and completly unoptimized. I believe I can even get much higher, it''s just a matter of getting more in tune with the actual display format.

So I would say that real game are not completly out of the question. You also have to remeber there are many advantages to a 100% or 99.995% ( jni not nessary, but optional ) programming. One thing would be the almost free porting to other platforms. Besides some testing and finding a good installed there is very little you will have to do for any system.

There are many drawbacks to straight java as well. You have to fight to get decent graphics speed, there are not many mature libraries to get you started, and the general stigma for the language.

And as for megalomaniac... we all have our days, but remeber that in many ways playability in a small game will beat a large game almost any day. When asking for transparency and such, remind yourself what you really need it for, and if there might be less costly possibilities insted. With your exmple you could rotate the view insted of trying to make things transparent. I have decided personally not to get into the 3d gaming because that would be way too much for a single part time programmer.

Some other things you can look into .... java & gl4java ( glOrtho mode ). With opengl you can get the transparency almost for free as well as many other neat tricks.

Good luck on your quest.

#4 Fovster   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 November 2000 - 07:58 AM

To felonius :

Your article was very interesting indeed, got me a little excited too!
I''ve been programming in java for ~2 years now, still i have many holes in my java knowledge. To confess, i''ve never had much to do with interfaces/abstract classes and such. Java was the first and only programming language i''ve had anything to do with, excluding a very basic course on C, and a very basic course on visual basic. The current game project is an applet, which made me wonder about how it would work. I had planned to run it in a 320x320 window, which is a little small.
I''ve been planning to get to know C, but have been too lazy (or afraid) to start with it. Maybe the largest reason has been that i haven''t been able to think about much use for it. Now i just might have.. In that case, though, i should probably dump the game project for some while to get to know the basics of JNI, C and DX first.

Snowmoon:

What kind of computer are you developing your game on? The FPS seem very nice to me, considering the size of your screen!

About the transparency thing.. The walls arent the only place i''d need to adjust the tile bitmaps on. I mean, of course nice gfx definately don''t make your game good, but if you''re trying to create something realistic and would like to use line of sight algorithm and stuff like that, it quickly becomes a must.
This project of mine isn''t 3D either. Just 2D tiles drawn from an isometric view. This makes rotating the view kind hard.. I decided not to go for 3D yet either, got to learn a little more maths first. I made a rotating wireframe sphere though

Considering all the things i had orignally planned for my game (LOS stuff, GFX effects etc.), the applet idea would probably not have worked on the first place.



Thanks for suggestions.

#5 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 19 November 2000 - 08:19 AM

well for one thing you shouldn''t use an applet if you plan on doing a big project. Applications give you more freedom. Are you even allowed to use Java2D in applets?

#6 snowmoon   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 November 2000 - 10:09 AM

I''m developing on a PIII 700. I do believe that I can get much more performace out of java too, it''s just a matter of knowing how to stroke the jvm into doing what you want it to do. Applets are not a bad start too, as they tend to keep you honest about portability and size. Bloated java apps are a killer. Java is a good language to work with as it is very unforgiving with errors, I find it''s much easier to track down a bug in java than it ever was in c or c++. You can do isometric 2d with the opengl or direct 3d libraries, but you would have to know the math first.

Yes you can do Java2d in a browser, but only with the java plug-in.

Good luck

#7 felonius   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 November 2000 - 11:15 AM

>>There are many drawbacks to straight java as well. You have to fight to get decent graphics speed, there are not many mature libraries to get you started, and the general stigma for the language.

I would like to note a thing about mature libraries. Using an high performance library for Java (such as Magician) removes the code from being 100% pure Java, as such libraries themselves use native code.

However, if you can get your hands on a library written by someelse then the clear benefit is that you don''t have to waste your time in C/C++, but can stay in Java. You should just be aware that the code being run was actual written in C.

In fact, large parts of the implementations of the Java standard library is also written in C or some other system level language (such as Pascal, Cobol or Fortran). This way such things as AWT routines are allowed to write to the graphics display.

All Java programmers should be very aware of the fact that Java is an "application level language" while C, Pascal, Fortran, and Cobol are "system level languages". For instance, you cannot write a OS kernal in Java, but you can in any of the others. This is not to say that Java is bad, just that there is somethings that it cannot do - there is however many advantages of Java, as programmer you must always use the right tool for the right job.
If I needed to write a printer driver, Java would be a bad choice.

Jacob Marner

#8 qurob   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 November 2000 - 05:36 AM

VB must be at least twice as fast as Java. And it''s way simpler! I started writing a Tetris game in VB, as one of my first games, and I got the majority of it done in one night. It took 2 nights to do that in Java, and I''m coming from a C++ background. Java is a nice tool, but it''s not the easiest thing to use, and it poses a ton of limitations, for all that it offers.

#9 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 20 November 2000 - 07:06 AM

quote:
Original post by qurob

VB must be at least twice as fast as Java. And it''s way simpler! I started writing a Tetris game in VB, as one of my first games, and I got the majority of it done in one night. It took 2 nights to do that in Java, and I''m coming from a C++ background. Java is a nice tool, but it''s not the easiest thing to use, and it poses a ton of limitations, for all that it offers.


A ton of limitations?!? I think you don''t know your languages. VB is a primitive piece of crap - and yes I know it and have written lots of programs in it at work - because I had to and I hated it.

First, VB doesn''t have proper classes. It doesn''t support inheritance. It doesn''t support polymophy in general (UDT are not objects) and the ways you can organize large projects are a hell.

As as for speed. I think you should read the article I gave to Fovster. Without native code compilers you might be right about speed, but with them it is the same speed.

VB is good for baby programs - but for serious projects forget it. It sucks. And trust me. I really know my languages.

Ok, I will quit flaming, but I really hate when people come and say something they don''t know sh*t about.

Jacob Marner

#10 qurob   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 November 2000 - 09:48 AM


There was this editor...for this game, they wrote it in Visual Basic....what game was it....oh yeah....Unreal!

VB can''t be THAT bad if they used it to make UnrealEd. Granted, it might not be the best it could be, but when''s the last time you seen a level editor for a highly rated 3D fps written in Java?

Enough about that. In my original post I was talking more about VB''s blazing compiled speed compared to Java''s speed. (oxymoron?)



#11 felonius   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 November 2000 - 10:59 AM

quote:
Original post by qurob
There was this editor...for this game, they wrote it in Visual Basic....what game was it....oh yeah....Unreal!

VB can't be THAT bad if they used it to make UnrealEd. Granted, it might not be the best it could be, but when's the last time you seen a level editor for a highly rated 3D fps written in Java?

Enough about that. In my original post I was talking more about VB's blazing compiled speed compared to Java's speed. (oxymoron?)



Such an editor could be made in any language you like. Even assembler. But would I do that? No.

COBOL and FORTRAN was used to build large financial systems that control a lot of bank even to this day. Does that prove that they are good languages? No.

And as I said, Java has compilers to that make machine code, just like VB. So again, these can produce just as fast code as VB can. Don't compare the speed of an applet or interpreted Java with the speed of compiled VB code - if you do, then yes Java is slower than VB. But then again, no serious games are made using interpreted code (well actually Vampire used interpreted code in scripts) so that comparison would be stupid. That like comparing the speed of a car with its engines shut off and a person walking. Just because the person go faster than the car it this case doen't make the man faster in all cases (the car engine might be turned on).

Finally, Editors don't require much speed. For instance, Quark (the Quake series editor) is written mainly in interpreted Python which is very slow, but serves it purpose here.

Jacob Marner

Edited by - felonius on November 20, 2000 6:01:42 PM

#12 snowmoon   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 November 2000 - 11:26 AM

I have to say most of you have not done large scale java applications. I have worked with java since 1.0 and am currently employed doing server side java applications.

I am not an expert, but from my knowledge of java, c, c++, perl, python, asm, lisp, and pascal most programs could be written in ANY language. I''m using java because it works, the development tools are free and it does what I need it to do.


#13 Fovster   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 November 2000 - 03:05 AM

bI''ve been mostly developing java on the server-side also, and think that''s where it should be used AFAIK servlets for example, are pretty much faster than CGI since they don''t need to spawn a new process each time a request is being made.

Applets then again i personally don''t like at all - except for graphics processing. They''re buggy and the browser support for applets is what it is. Just started looking into c++ a few days ago, seemed pretty hard at the first point, but it begins to slowly make sense already..

Dunno if this was totally off-topic, just wanted to express my point of view.

By the way, Felonius, if JNI should be used at game programming, what kind of tasks did you think to use a lower-level language for? Surely some computations, but did you plan to use it for the gfx presentations etc? If yes, then in which way? I didn''t quite get that, should i have after reading your article etc?



''''2+2=5 for extremely large values of 2.''''

#14 qurob   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 November 2000 - 03:52 AM


Are you stupid? Compiling Java to an EXE or what not still doesn''t make it very fast. Another thing it does it takes away the whole point of using Java-Platform Independence. If you plan on writing games in java and just letting the windows users have > 5 fps, you may as well do it in C/C++ or Visual Basic.


---------------------------------------------------------
And as I said, Java has compilers to that make machine code, just like VB. So again, these can produce just as fast code as VB can. Don''t compare the speed of an applet or interpreted Java with the speed of compiled VB code - if you do, then yes Java is slower than VB. But then again, no serious games are made using interpreted code (well actually Vampire used interpreted code in scripts) so that comparison would be stupid. That like comparing the speed of a car with its engines shut off and a person walking. Just because the person go faster than the car it this case doen''t make the man faster in all cases (the car engine might be turned on).

Finally, Editors don''t require much speed. For instance, Quark (the Quake series editor) is written mainly in interpreted Python which is very slow, but serves it purpose here.

Jacob Marner
----------------------------------------------------------


#15 Fovster   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 November 2000 - 04:19 AM

Qurob, you don't seem to be getting the point of the native stuff at all do you? Go read the felonius' article again
The point is the simplicity of java compared to c/c++, if i got it right. Besides using JNI for critical parts of the game, it does get a _little_ more speed.



Edited by - fovster on November 21, 2000 11:22:01 AM

#16 felonius   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 November 2000 - 04:40 AM

I am sorry, you other people on this forum, but I am getting quite angry. Please forgive me.

quote:
Original post by qurob
Are you stupid? Compiling Java to an EXE or what not still doesn't make it very fast. Another thing it does it takes away the whole point of using Java-Platform Independence. If you plan on writing games in java and just letting the windows users have > 5 fps, you may as well do it in C/C++ or Visual Basic.



No, I am not stupid, but you are ignorant. You don't win a discussion by calling people names. Arguments win.

qurob, are you thinking that am I talking about packing Java in a an EXE like Microsoft J++ does. Yes that is slow, but that is the way with many Microsoft tools.
But the native compilers for: GJC, Visual Cafe 4, IBM Visual Age are actual producing pure machine code. Have you ever tried one of these? If not, then shut up.

GJC is just a different front end to gcc and the code it produces uses the same code as for gcc - the compiler used to produce all the utilities in Unix - including Linux. And gcc has a better optimizer than VB has (the VB optimizer is actually quite inefficient).

Oh, and by the way; Using the scheme in described in my article where I combine C++ and Java (because 100% pure Java does has its limitations for high performance applications) I am using a Quake II styke engine running with more that 35 frames per sec - within my Java code. Admittedly this isn't pure Java code, but try reading that other thread that snowmoon has posted with framerate - and then go home a weep.

Oh and you compare platform independant Java with platform dependant VB and see it slower. Of course - platform independance is slower that platform dependance. That is why I am making sure that they are compared on equal terms by using compiled code in both cases.

Anyway, speed isn't everything. Is it was everybody would still use assembler. Productivity is a major issue - and for large scale products Java is more productive that VB.

And for speed in games you are probably referring to the DirectX support in VB. DirectX is itself written C and by calling it from VB is no different than calling C/C++ from Java. Very comparable, actually.

Jacob Marner

Edited by - felonius on November 21, 2000 11:51:32 AM




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