Author Topic: Java vs C++ Discussion  (Read 9657 times)

0 Members and 1 Guest are viewing this topic.

Java vs C++ Discussion
A bit off the subject, I'm super happy right now.  I just FINALLY[/COLOR] got OpenGL libraries sucessfully working with Java.  I can do OpenGL Programing under Java now.  I'm working on getting JSDL (Java for SDL) libraries installed next.  I'm sorry if this is off the subject, but I been working this thing out for over 4 months.  I'm totally siked! :)
The big cool ship...

 

Offline Grug

  • 211
  • From the ashes...
Lol.
Awsome. I'm also a Java programmer. :D

I havn't gotten around to learning the OGL libraries for it though.
So what were you planning to do with it?

 
Chrome is a game of which was made by Java around the year 2000-2001. It was finally published around 2002.

I plan to make games with Java.

I believe Java would be far more suitable for game developement because it is cross-platform compatable.  C++ is as well, but requires lots of code adjustments to work between each and every system.  Java does not require code adjustments.

I believe OpenGL is a far better library then DirectX.  I also believe that focusing on OpenGL opens more cash-flow for companies, such as Blizzard Entertainment.  I say this because by developing a game for OpenGL, the software can be used on Windows, Mac, UNIX and Linux.

If you combined the universal use of OpenGL, and the Universal use of Java, I see more money, less headaches, greater security.  Another thing that bothers me about C++ (Or C#) is the .Net.  There are some serious security issues with it.  Java can work under MONO, which works much the same as .NET without the security issues.

I believe Java is easier to use, if you can get past learning it.  C# is pretty much the same thing as Java as far as Syntext goes.  In addition, powerful tools, such as Netbeans is free for Java Programing.  MS Visual C++ is not.

In a nut shell, I see Java vs C++ more the same as I see Linux vs Windows.  I think C++ is fantastic and I know it was not made by MS.  But I also see C++ as more work and less cost efficient.

That's my 2 cents.
The big cool ship...

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
The problem with Java however is that it's inherently slower than C++. Yes you can write games in it and pretty good ones at that but if you're really pushing the machine then Java isn't the right language to use.

That said C took over from assembly because it was easier to use, with machines getting faster it could happen again but I can't see it happening any time soon.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline aldo_14

  • Gunnery Control
  • 213
I use Java - hell, my job is programming in Java, at least until next week - but I wouldn't use it for games programming.  Problem with Java is that the interpretative nature of it (the virtual machine abstracts out hardware differences and converts java to VM bytecode to machine code) both creates a slowdown, and locks out control and optimisation over machine-level details.  And it's these things you need to work with to maximise speed.

That said, there is a bit more work been done with, in particualr, graphics on Java - there's support for DX and OGL (both directly and via Java3D libraries), and AFAIK support for using GFX hardware to speed rendering.  

But I don't think you'd be getting anywhere near the same level of optimized performance with Java as you will with C/C++ ever (but overally performance will improve to a state it doesn;t matter).

I'm also intending to learn OGL, but I'm planning on learning C/C++ alongside.  The only Java graphics programming I've done, has really been in very basic 2D mainly using my own libraries, which are crap. :)

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Basically what I was going to say but I couldn't be bothered to explain it all :D

BTW We're going to need to get an admin to split this off to somewhere cause it's completely OT and in an important thread.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 
Hahaha! :lol:

I don't blame ya.  I was way to excited about my sucess.

Hey, can these plug-ins be made in Java?
The big cool ship...

 

Offline aldo_14

  • Gunnery Control
  • 213
Quote
Originally posted by xenthorious
Hahaha! :lol:

I don't blame ya.  I was way to excited about my sucess.


Nowt wrong with that :)  I've been meaning to learn OGL with java as well.... actually intended on designing a single simpl game and implementing it in 3 methods; java+OGL, c++ and OGL, and a hybrid using c++ code for the graphics engine and java for the game engine (idea being that you could replace the graphics engine based on the platform - i.e. a nice 3d-fixed-view engine for an RTS on Pc, and use a simpler 2D engine for a PDA version, yet keeping enough common code to allow multiplayer to occur between both)

Hellish finding the free time, though...

Quote
Originally posted by xenthorious

Hey, can these plug-ins be made in Java?


Max plugins?  I think they're written in a max scripting language.

 

Offline Grug

  • 211
  • From the ashes...
lols cool.

There was some guy making a Java game engine. He had it highly optimized which was quite surprising how well I got it to run with an insanely high amount of poly's on screen.
True though, that there wasn't much else other than landscape, and about 300 fighter planes with 2-3 variants.

But still, for SMALL games, Java would kickass.
I've been meaning to learn C++, but its a difficult thing to be self taught...

Actually, I might as well say here anyway, but I was intending on writing a small app for someone in my line of modding when it comes to FSO.
I spend a lot of time photoshop -> wpn tables -> test ingame ->tables-> test ingame etc etc,
I want to cut the test ingame part out.
So you have a table reader that reads the weapons then renders what it will look like ingame, and also another window where it shows what it will look like at its max fire rate, and other details.

Would save alot of time messing around...
« Last Edit: March 26, 2005, 04:01:23 pm by 501 »

 
I was thinking, and here's my thoughts:

>C++ and Java can work on any system, but only java can execute on any system without changes.
>Why is C++ different, and how could we change C++ to be the same as Java without losing the performance difference?
>What is java known to be good for: Middleware.
>So if Java is good to be known for middleware, but middleware and the way Java works, degrades performance, how can we eliminate this?

Then this simple word came through my mind; Polymorphism.

How is this one method of programming so valuable in this circumstances?

Correct me if I'm wrong, but the biggest cause for why so many values in C++ need to be changed is because of how the program with associate with the operating system.  So let's say, we made a Java program that operated as a System Ananlist, which evaluated everything on the operating system of which it felt the program would need.  Let us say, it collected the information, and after feeling the program could run; passed the information to a C++ program which compiled the information to an understandable format for the program by working directly with the java program.  The C++ program then instanciate the values from a script file of which that first C++ program generated.  At this point, the Java program and the first C++ program would be shutting down.  After the values were pulled, the program would then go online, and operate with the operating system directly based on the values it found on that script file.  Java would ultimately be the responsable data member of which allowed C++ to work on any computer without the limitation of slow performance from how Java works.

In a nut shell, if Java would simple collect the information of the operatign system, and have the first C++ program compile it to a usable data, then final and main program could operate on any operating system because any value of difference between each and every operating system would be made the same.

Does this sound like a valid hypothephis?
The big cool ship...

 
C++ is inheirently more flexible and will probably be around for a very long time. Its also more stable and resource efficient.

I say stick with C++ but thats just me. Make your own choice.

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
If you build from the ground up to be portable, it's really not that hard to run a C++ program between two computers. If you wanted to write a game to run on a PDA or something, write it for Linux and keep the graphics code separate from all of the game do-stuff code. :D

Also, there's virtually no difference between C++ and Java when doing mathematical calculations (Under windows, at least). I think Microsoft has some sort of proprietary program that converts Java files to native code when you start them.
-C

 

Offline Grug

  • 211
  • From the ashes...
Java can't run on any system without changes always.
It can do that, if you design your program to do so.

But if you design your program correctly (laughs) with UML etc, then the basic outline of classes etc should be the same between Java and C++. But there are still quite a few changes between them.
C++ for example doesn't have such a strict heirarchy to follow.

But hey, if you goto do a small project in Java xenthorious, I wouldn't mind helping out or being a part of the design / implementation. :)
I've been meaning to develop some small time apps of my own, but havn't touched Java in a long while...

 

Offline aldo_14

  • Gunnery Control
  • 213
Quote
Originally posted by xenthorious
I was thinking, and here's my thoughts:

>C++ and Java can work on any system, but only java can execute on any system without changes.
>Why is C++ different, and how could we change C++ to be the same as Java without losing the performance difference?
>What is java known to be good for: Middleware.
>So if Java is good to be known for middleware, but middleware and the way Java works, degrades performance, how can we eliminate this?

Then this simple word came through my mind; Polymorphism.

How is this one method of programming so valuable in this circumstances?

Correct me if I'm wrong, but the biggest cause for why so many values in C++ need to be changed is because of how the program with associate with the operating system.  So let's say, we made a Java program that operated as a System Ananlist, which evaluated everything on the operating system of which it felt the program would need.  Let us say, it collected the information, and after feeling the program could run; passed the information to a C++ program which compiled the information to an understandable format for the program by working directly with the java program.  The C++ program then instanciate the values from a script file of which that first C++ program generated.  At this point, the Java program and the first C++ program would be shutting down.  After the values were pulled, the program would then go online, and operate with the operating system directly based on the values it found on that script file.  Java would ultimately be the responsable data member of which allowed C++ to work on any computer without the limitation of slow performance from how Java works.

In a nut shell, if Java would simple collect the information of the operatign system, and have the first C++ program compile it to a usable data, then final and main program could operate on any operating system because any value of difference between each and every operating system would be made the same.

Does this sound like a valid hypothephis?

@grug
Java is intended to be machine-independent, though.   Whereas C/C++ that's left up to the programmer (in Java any problems are basically a maturation issue).

----

The pain-in-the-tits aspect of C, IIRc, is handling memory allocation, pointer, etc; at the same time, that's where you can finetune performance, which is why odds are a well-written C/c++ program will be faster than a well-written Java one.

The aspect of speeding up java on machines by compiling to assembly is a fairly simple one, albeit relying upon optimizing compilers.  The main problem, IIRC, is that Java doesn't run in that way.  It runs over 2 stages; java bytecode on JVM, and JVM on machine.  If you switch to compiling directly to machine code, then you move back to the C++ model (so why abstract out any machine details?) - but it means you have to compile on every machine.

That's a problem - one of the main advantages of Java is not only that a class file will run unaltered on multiple architectures, but that a distributed system can dynamically distribute and run those classes.  for example, agent systems (mobile code that moves and executes between hosts).  Or what I've been working no for the last 36 weeks, which will require (for lack of a better term, and to avoid giving patent info away) servers to be dynamically and rapidly relocated to new physical hosts.

In all those cases, requiring recompilation sacrifices (switch) performance, and also places external requirements upon the host environment.  You go from 'write once, run anywhere', to 'write once, run anywhere which has the right stuff'.

Move to - concretely- supporting local compilation, and you risk sacrificing this ability.  And you lose one of the reasons for selecting Java over, for example, C or C++.

Ultimately, if you want to maximise Java performance, what you need to do is optimize your bytecode, and hope Sun optimizes the arse off of the local JVM.....

NB: not really fair to compare C++/Java - both have different purposes, different stages of maturation and use.  It's been suggested to me (by professors nonetheless), that there's increasingly less benefit learning C++ as an adjunct to Java compared to C.  In the business world, that may be true.

 
java :ick:

What I really think is that you can't compare a compiled language, such as C/C++/Pascal/whatever else, with an interpreter, like perl/php/java. Indeed, there are different purposes for these languages. I think I agree with Aldo on this.

And for great games, like Freespace you can't use Java :D

 

Offline phreak

  • Gun Phreak
  • 211
  • -1
The reason i wouldn't like making a game in Java, is that you can't deallocate memory on demand like you can in any other language in existance.  Using a freespace example, you don't want the briefing images still loaded into memory once you've launched into a mission.  Additionally, you don't want any other critical things such as ship textures and model data to be garbage collected while the player is still in the briefing (since they are already being used).  Hell you don't even know when the garbage collector will run, so something could crash in mid-mission.  I guess that could present a small problem.  Plus pointers are fun.
Offically approved by Ebola Virus Man :wtf:
phreakscp - gtalk
phreak317#7583 - discord

 
There are ways to remove features such as this without having to use the garbage collection.  Also, though not garenteed, if you set all processes to minimum priority, you increase the opitunity of garbage collection.  So let's say between stages of each part of the game, you put all processes to sleep for 3 seconds.  That's 3 seconds garbage collection can conclude it's job.

Again, there are ways to avoid stuff like, texture mappings, to be handled by the garbage collection.  It all comes down to how you program the code.
The big cool ship...

 
Quote
Originally posted by Grug
But hey, if you goto do a small project in Java xenthorious, I wouldn't mind helping out or being a part of the design / implementation. :)
I've been meaning to develop some small time apps of my own, but havn't touched Java in a long while...


I do have a small project in the works, but it is unrelated to Hard Light Productions, and/or OpenGL.  If anything, it is a client-to-server console of which operates and maintains a NWN server.  http://nwn.bioware.com.

I am totally new to Java; just finished learning about how to write stuff to files.  But I can make a GUI like a pro, thanks to tools I use.  =)

Here's some examples:





I have plug-ins for 3DS to make models for NWN.  If this project finishes, I might be tempted to putting in a NPC spawn controller, which would require the use of OpenGL libraries to display a small sample of each NPC in 3D format.

In addition, this software would need to be used directly on the server itself.  I may be tempted to putting in some network interfacing, so it can be used remotely from the server.

Anyways, this is a bit off the subject, but you asked, and I offered.
« Last Edit: March 28, 2005, 01:01:04 am by 1975 »
The big cool ship...

 
Quote
Originally posted by xenthorious
There are ways to remove features such as this without having to use the garbage collection.  Also, though not garenteed, if you set all processes to minimum priority, you increase the opitunity of garbage collection.  So let's say between stages of each part of the game, you put all processes to sleep for 3 seconds.  That's 3 seconds garbage collection can conclude it's job.

Again, there are ways to avoid stuff like, texture mappings, to be handled by the garbage collection.  It all comes down to how you program the code.



hah.. garbage collector... /me pukes :P

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Quote
Originally posted by PhReAk
Additionally, you don't want any other critical things such as ship textures and model data to be garbage collected while the player is still in the briefing (since they are already being used).


If that's happening in your Java program then you've done a really bad job of writing it. Garbage collection of items you wanted to keep occur would only occur if you were silly enough to have no references to the object even though you wanted to use it again. You can do that in C just as easily. (not to mention that you can have references to an obect that no longer exists because you've called the destructor, something you can't do in Java).

So if you're having objects collected that shouldn't have been in Java you would still have had them out of the scope of your program in C and now would have to contend with a memory leak too.



All that said I don't think Java is a good language for writing games in.
« Last Edit: March 28, 2005, 02:06:21 am by 340 »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]