 |
|
Mark_Everson
|
 |
Canton, MI
Jan 1970 time: 00:17
|
|
The Java vs C++ issue comes up every now and then...
I came across an article that looked pretty good on this, and I figured I'd start a thread on generic Java Game Programming issues. As time goes by and there are a few more things in it, and perhaps some discussion, it would be something that we can just point people to when these issues come up.
The article is Evaluating Java for Game Development
A Very useful resource is the Java Development forum at Gamedev.net
[edit, remove deadlink]
Last edited by Mark_Everson on 15-12-2002 at 01:52
|
|
|  |
 |
|
DJ
|
|
Well, I'm learning Java... but there's nothing to learn cuz it's JUST LIKE C++. lol, unless you don't know how to use classes. I bought a J++ compiler a long time ago, I just have to get it back up, for the last few years I've been doing a lot of C++ development.
MY LATEST PROJECT: here (Just my own 3D Modeler so i can have my own model format)
Anyways, the only part I don't like about Java is that I don't think there's a way to do dynamic memory allocation.
|
|
|  |
 |
|
Mark_Everson
|
 |
Canton, MI
Jan 1970 time: 00:17
|
|
Hi DJ:
Why exactly do you want to do dynamic memory allocation? It is tedious and bug-ridden and best thrown into the dustbin of history .
From the Java Hotspot Whitepaper
quote: A major attraction of the Java programming language for programmers is that it is the first mainstream programming language to provide built-in automatic memory management, or garbage collection (GC). In traditional languages, dynamic memory allocation is done using an explicit allocate/free model. This turns out to be not only one of the largest sources of memory leaks, program bugs, and crashes in programs written in traditional languages, but it is also a performance bottleneck as well as a major impediment to modular, reusable code (determining free points across module boundaries is often nearly impossible without explicit and hard-to-understand cooperation between modules). In the Java programming language, garbage collection is also an important part of the "safe" execution semantics required to support the security model.
A garbage collector automatically handles "freeing" of object memory behind the scenes by only reclaiming an object when it can "prove" that the object is no longer accessible to the running program. Automation of this process completely eliminates not only the memory leaks caused by freeing too little, but also the program crashes and hard-to-find reference bugs caused by freeing too much.
Traditionally, garbage collection has been considered an inefficient process that impeded performance, relative to an explicit-free model. In fact, with modern garbage collection technology, performance has improved so much that performance is actually substantially better than that provided by explicit freeing. |
|
|
|  |
 |
|
DJ
|
|
yea, but don't you feel like you have more control somehow. i do...
|
|
|  |
 |
|
Gary Thomas
|
 |
New Zealand
Mar 2001 time: 17:17
|
|
quote: Well, I'm learning Java... but there's nothing to learn cuz it's JUST LIKE C++. lol, unless you don't know how to use classes. | What!!!!!! Java has no evil pointers, Java has automated garbage collection, Java has proper interfaces, Java got rid of evil enums, Java has reasonable GUI system (not good, but reasonable), Java is platform independent without recompiling, Java has an extensive library, Java has strings built in, Java is internet friendly.
quote: I bought a J++ compiler a long time ago, I just have to get it back up, for the last few years I've been doing a lot of C++ development. | J++ is NOT Java, it is Microsoft's failed attempt to hijack Java. Download the basic JBuilder (it is free) from Borland. This uses the Java JDK 1.3. I am not aware of any serious programming that has ever taken place in J++.
quote: Anyways, the only part I don't like about Java is that I don't think there's a way to do dynamic memory allocation. | All Java memory allocation is dynamic. Try:
int[] intArray = new int[100];
for example. The ONLY non-dynamic memory use in Java is for non-array primitives (unlike C++).
On the other hand, if you mean malloc and its friends, assembler does it much better and is even harder to write...
|
|
|  |
 |
|  |
 |
|
DJ
|
|
Hehe, nah, I dont' mind, I like to hear opinions. I still think C++ will remain more powerful tho. I think i'll stick with C/C++ after my Java classes are over. Plus, all my 3D projects are coming along fine with C++ and they're fast, (do to my unique fustrum culling and octree techniques ). I suggested to my friend (in my java class) that if he wanted to continue Java than he should join this project, but I think he's going into 3D game development with me, (hopefully publish my 3D game project I'm currently working on), and he wants to do it in C++. It's just faster and I feel it's more efficient (just my own opinion). Plus, I was told by some college kats and professors that I'm good at C++ and that I shouldn't switch because it's the "virtual god" of languages, that's what they told me, so that's what i'm doing. I'll learn java on the side tho, it's just hard for me to imagine making games with it, although I admire this game because it has potiential and I'd tell all my "java" friends that this is a good project to invest in. BTW, you only have problems with pointers if you don't know what you're doing. I myself have my own 3D engine that calls up all types of pointers and I can handle them fine. I love pointers because I can manipulate and modify so many things with them, gives me control (that thing that drives programmers). I had a problem with pointers back when I was 14 years old, and even then it wasn't as bad as you guys say it is (geez, I was so young, does this say something?). Dont' be afraid of them guys, love them and they will love you. Love assembly code and you'll be amazed at your computer's potential!
You should see the glory of democracy in C++, the great amount of freedom (that comes with some corruption). In C you are FREE! Hopefully it'll pay off when I move back to maryland 
Sorry it took so long to reply, I was at work 
--Sorry kids, but Java will actually stunt your growth. If you ever hope to be a "master programmer" you'd better get real dirty, real soon. At 14 I was interested in Motorola 6502 assembly programming. If your only interest at this critical stage of development for you is in becoming another Java drone, I think I can safely say to you in advance that, no, I do not want fries with that. --Doc O' Leary
Last edited by DJ on 03-02-2002 at 11:44
|
|
|  |
 |
|
F_Smith
|
|
Austin, Tx 78728
May 1999 time: 05:17
|
|
BTW, you only have problems with pointers if you don't know what you're doing.
Hmmm. Are you suggesting you've never made mistakes with pointers?
Unless I misunderstand, you're still in college. I don't mean that as a knock, just an observation. At my company, when code gets written on deadline, as it always is, mistakes always happen. Even to the best developers. We work long days, sometimes long weekends, putting releases to bed. Mistakes happen. Once out of college, you'll find that it's not so easy writing bug-free components under pressure.
Especially when you have to match up delivery times against Java developers who don't have to debug that stuff. We're finding a comparable Java component can be built in about 2/3rds the time, on average. That makes the Java component cheaper to produce, to boot.
Don't get me wrong, Java isn't for everything -- yet. It's slightly slower at certain tasks. If you do hard-core number crunching or serious 3d, you likely can't use it yet. Then again . . .
If speed is the only issue, then within just a few short years, I think technical advances in computing will completely remove that issue. Soon, these machines will be so fast that it just won't matter. And besides, if you save $50,000 on development you can just throw a honkin machine at the solution and *still* come out ahead.
So it's better all around if the language doesn't give the developers the power to shoot the consumer in the foot. It protects the consumer from the developer. Pointers are what the developer wants, of course, it gives you the power to create, and the power to destroy. Without pointers, you only have the power to create. And the consumer gets safer software.
I wonder, out of curiosity, what you think of C# and .NET?
|
|
|  |
 |
|
LDiCesare
|
|
La Ferté sous Jouarre France
Jan 2001 time: 05:17
|
|
The point is that java allows faster development than C++, and in any large scale project, there is always some bad programmation done, due to lack of skills, time, resources or foresight. And in C++, the consequences are worse than in java. However, you are right that right now C++ is faster than java and can give more control on memory. However the time you spend debugging a C++ program can be spent tweaking and tuning java, so in the end, it is not sure java will be slower.
|
|
|  |
 |
|
Gary Thomas
|
 |
New Zealand
Mar 2001 time: 17:17
|
|
quote: --Sorry kids, but Java will actually stunt your growth. If you ever hope to be a "master programmer" you'd better get real dirty, real soon. At 14 I was interested in Motorola 6502 assembly programming. If your only interest at this critical stage of development for you is in becoming another Java drone, I think I can safely say to you in advance that, no, I do not want fries with that. --Doc O' Leary | A quote from a moron. If making programming harder is important, program in assembler, or better still, machine code. All this mamby-pamby high level language stuff (like C or C++) will surely stunt your growth. See the entry in the New Hacker's Dictionary on "Real Programmers" for a description of how real programmers work. Of course their code can never be modified or even maintained, but is that important? After all, we real programmers never have to meet deadlines or fix defects, we just cruise in la-la land.
|
|
|  |
 |
|
F_Smith
|
|
Austin, Tx 78728
May 1999 time: 05:17
|
|
When Java does get better he'll probably need to choke on his words, but until then it's just not good for major development applications.
Pssst . . . Java is now the development language of choice for new dev. You should check the jobs postings on any of the job sites. There are more Java jobs than C++ and VB jobs, and the Java jobs pay better.
There are actually more Java jobs than C++ jobs even in Seattle.
Last year, new Java projects passed new C++ projects. Java completely dominates server development, and the 1.4 release will do to desktops what the 1.2 release did to servers.
The next release, 1.4, is when Java on the desktop turns the corner. There's even a Java games and 3D api's.
You might be interested in the 3D api. It's rather amazing. You just define the objects in the world, their dimensions, surfaces, etc, and then define any light sources and where the 'eyes' of the viewer are, and all the methods for moving around in the world and viewing the world are done for you. And it's very fast, and uses any hardware acceleration, and will use OpenGL.
|
|
|  |
 |
|
Plutarck
|
 |
Earth
Nov 2001 time: 23:17
|
|
As for the 3D power of java, MAN has it taken huge jumps forward!
Check out this: http://www.javagaming.org/
Note the Java3D(tm) Gran Prix vs F1 2001 - Electronic Arts article.
Looking at it I'm almost stunned that it's done in Java3D.
Oh, and about the Doc O' Leary quote. It brought to mind a quote from some other amazingly misguided individual about how learning VB would "ruin a programmer for life".
It's all the ancestor of the "If you keep doing that, you'll go blind/to hell!" scare-tactic, used to control the actions of people through fear of an unreasonably severe consequence; if actionX is such a minor action, but it would result in the extremely severe resultY, then actionX must be avoided at all costs - and you wouldn't want other people to suffer from resultY, so you'd better tell other people about it too.
You'll find it permeates old wives tales, urban legands, and most noticably- religion (of all kinds, including Programming). A technique passed down from time immemorial, usually leading to devastation of intellect, spirit, and psyche. In other words, repression.
But look deeper at this particular assertion. It raises the following questions:
1) How does the speaker know this?
a) Did he learn it himself? If so he must have been stunted. Do you really think such a gimped programmer should be heeded?
b) How can he chart the progress of programming skill at all? To be "stunted" means to slow down in advancement/growth, which requires there be some normative mean to use as comparison.
But there is no such valid mean to apply to programming skill. Hell, it's hard enough just to measure such skills at all.
Taking me for instance, in my early efforts to program I made little headway and quit multiple times over a few months. Looking on it could seem "stunted". That would be because you only evaluated the failures.
Yet if you took notice of advancements when I restarted learning and charted it over 1-2 years, calling any part of it "stunted" would be pointless. As in most things there were many starting failures, which gave way to considerable success (in this case, increase of my understanding of programming theory and it's application to design).
c) Just what kind of "programming" is this pointed towards? Shifting bits around is important in low-level programming and is a high-rated skill, but in high-level programming it's a skill that is almost entirely unused. A good high-level programmer is not a good low-level programmer, and vice-versa.
There is also network programming, non-UI programming (for instance, creating a thin-client), UI programming, scripting, graphics programming, audio programming, RAD, and object-oriented, procedural, and structural programing, and many many more. And all draw from many sets of general and specific skills and abilitys.
How could learning ANYTHING manage to stunt programming ability as a whole? Does that sound like a reasonable assertion?
2) He's still full of ****.
When it comes down to it, "practical programming" is about getting things done the best way possible. That means fastest, cheapest, most effective, and most robust (ie- secure, extensible, maintainable, etc).
Programming Languages are all tools, and nothing more.
There is no Perfect Tool in existance which can handle every job better than any other tool. The best tool to build a word processor or a manual-style calculator is not the best tool to build an all-out realworld physics 3D graphics engine. And when building a 3-tier design network application you'll probably use something entirely different.
But in the end, in life you rarely ever reach an Optimum anything.
Sure, building that simple website with a search engine would have been alot easier with ColdFusion, but you don't know ColdFusion, and that's about the only thing ColdFusion will ever be useful for.
Sure assembler is great, but it's only good uses are for small super-performance reliant apps, optimizing performance-reliant programs (which breaks their system independence), reverse-engineering/cracking/editing binarys, and a few ground-level coding tasks. Unless you're going to do low-level programming (which I do approximately zero of), it would be a largly useless tool, good only for your personal development while learning it.
Java is basically a high-middle level language. Not as high level as some, but it's high enough to keep your boots out of the bits - so to speak.
That makes it easier and faster to learn, easier to use, do more in less time, it's less bug-prone, more secure by nature, easier to write secure code (assuming you know what you're doing), and allows high-level broad designs to be more easily implemented.
And that's just for the level of language, not to mention any of it's features.
It's not perfect, but nothing is...*sigh*
|
|
|  |
 |
|
Plutarck
|
 |
Earth
Nov 2001 time: 23:17
|
|
Btw: Confucious say, "Work smarter, not harder."
As for C#, it's slated as the "Java killer". I believe that as much as I believe Delphi killed Visual Basic. (in case you didn't know...it didn't)
What I wouldn't be surprised about is if they ended up just jockeying each other back and forth on new features, kind of like the relationship of PHP to ASP.
I've heard that Java would have more to copy from C# than C# would have to copy from Java, but I have seen nothing convincing in that regard.
But I'll sum it all up right now: The idea of language-neutral code- Good Thing. In the real-world it's a Nice feature- and that's it.
It's a whole hell of a lot less important than they like to pretend, and will lead to some incredibly stupid ends. Writing a program in more than 1 language is like writing a book in more than 1 language- you can, but why the hell would anyone think that's actually a good idea?
At most you should have 1 main language and 1 minor language, like Java and C++ (for instance). But the fact is, Java not only has the potential, but it already does it! That's what the Java Native Interface is for!
But the JNI does kind of suck to use, or so I've heard, but already there are products which act like a wrapper to do the work of JNI even better, such as functionX (I think it's called that...).
Other than the fact that Microsoft is interested only in dominance and nothing more (and willing to use any tool to obtain it, which has varying effects on The Rest of Us), Java has years of a head-start and Sun has said many times they want to release it as totally open-source when the option becomes a good one (they say they haven't done so to protect some company from coming along and producing a proprietary version of it, ie- Microsoft).
In the words of a wise man, "Good software takes 10 years" http://www.joelonsoftware.com/artic...0000000017.html
And C# isn't even really "out" (ie, not beta...but then again, MS products never go out of beta...hee, hee, hee) yet, compared to Java's maturation time.
It'll be at least 2 years before C# becomes a truly Good Idea, if not 3-5 years. Assuming it "takes", which it likely will. .NET is a lot bigger of a gamble, but if MS doesn't go extinct then it will stick too. They're resilient bastards, to speak highly of them, and they'll keep releasing new versions, each time slightly growing it's popularity.
But it won't kill Java, though it may however 'kill' Delphi. But the majority of java's turf will stay under java, and the majority of MS's turf will migrate to C#, which might be good for all of us.
C# may even be worth learning, but not now, and could be a fun thing to play with or even use. But hell, Java 1.4 finally fills out almost all my demands for a language - along with all the other java development products I desire - so I'm quite positive it'll be quite the long time before C# manages that.
I do look forward to third-party support for Java in .NET though, and there are many iiiiiiinteresting plans for reverse-engineering C# itself, if not .NET along with it.
If someone adds PHP support somehow too, that'd be excellant too. But as I said, it'll be a few years before C# becomes a viable choice.
|
|
|  |
 |
|
DJ
|
|
would C# be good? I was thinking about getting a book on it once I get the new Visual C++ .Net compiler, COME OUT ON FEB 13 hehe, i'm so excited!
BTW, kestrel email:kestrel18@bigpond.com was from this forum. if so, why'd you send me a virus just now?
Last edited by DJ on 05-02-2002 at 02:48
|
|
|  |
 |
|
LDiCesare
|
|
La Ferté sous Jouarre France
Jan 2001 time: 05:17
|
|
Using HashMaps is not evil per se. It is just you don't put all your data in hashmaps, and you use hashmaps as private data so that they are only accessed by setTyped() and getTyped() methods. For example, the list of unit archetypes is a hashmap, but it is an implementation detail.
|
|
|  |
 |
|
colorrr
|
|
quote: Originally posted by DJ
... Anyways, I dont' have any solid views on C# or .NET as of yet, I'm really hoping to try them one day, just out of curiousity. ^_^ |
Here's a phrase from ZDNET that should help you:
Microsoft's C# is like Java with the 'reliability, productivity and security deleted'
|
|
|  |
 |
|
colorrr
|
|
quote: Originally posted by DJ
I always thought Java should stay in the internet domain, it seems better and more at home there than anywhere else. Maybe that's Java's true destiny, the internet... |
What you are saying is exactly the opposite of what causes growth, evolution and enhanced productivity.
If everyone were to stay put in their boxes, not trying to break the limits, then we would not have Java 3D, nor Java nor C or C++ for that matter. We would still be stuck in Cobol. If programming ever existed.
I think it's time you open your eyes and explore the wide world of programming, there's a lot more to it than just programming C or C++. Personally I developed from C++ to Java, finding Java much better as it allowed me to think more in the design and less in small details, like pointer allocation/deallocation.
It was nice to be able to manipulate everyting, but with a good design, you don't really need to do 'dirty tricks' to make things work.
|
|
|  |
 |
|
colorrr
|
|
Hey guys,
Java 2 SE 1.4 is just out
read the specs
Some interesting cuts from the page:
"The AWT improvements include ... high-performance graphics which draw directly to the screen. (This latter feature is the equivalent of working with DirectX on a Microsoft Windows platform or SunTM OpenGL® for SolarisTM.)"
"We know of several game vendors who are just entering the Java game business because they can now deliver full-screen games, which finally puts them on equal footing with platform-specific games vendors."
Jorgen
|
|
|  |
All times are GMT. The time now is 05:17. Apolyton Time is 00:17. |
top of page
|
|
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|