Announcement

Collapse
No announcement yet.

Java Game Programming

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java Game Programming

    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; December 14, 2002, 16:52.
    Project Lead for The Clash of Civilizations
    A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
    Check it out at the Clash Web Site and Forum right here at Apolyton!

  • #2
    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.

    Comment


    • #3
      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

      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.
      Project Lead for The Clash of Civilizations
      A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
      Check it out at the Clash Web Site and Forum right here at Apolyton!

      Comment


      • #4
        yea, but don't you feel like you have more control somehow. i do...

        Comment


        • #5
          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.

          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++.

          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...

          Comment


          • #6
            Gary, are you kidding? Don't you love debugging code which crashed because a delete had been done on some pointer and it wasn't null so it would only crash once in a while? Or debugging buffer overflows because you allocated a char[256] and some *#^!* typed a 260-char long string? Or discovering that type XXX is a typedef of a typedef of a #define that has been redefined in another .h you just have to include?
            With java, you also miss the joy of managing multi-threaded programs by hand, so that you have to check by yourself all access to all variables instead of using a puny synchronized keyword?
            And what about spending one day on a nasty bug before you realize somebody saved an int to a file and rereas it without any consideration of the fact that it was written in little-endian and read in big-endian?

            No, java is a poor language, as debugging is harde than in C++. But that's because there are less bugs.
            Clash of Civilization team member
            (a civ-like game whose goal is low micromanagement and good AI)
            web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

            Comment


            • #7
              DJ:

              Should I call off the "Java Dogs" or have you not had enough yet?

              This is probably not a good place to advocate the "Power of C++" which vs Java is mostly the power to shoot your own foot off...
              Project Lead for The Clash of Civilizations
              A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
              Check it out at the Clash Web Site and Forum right here at Apolyton!

              Comment


              • #8
                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; February 3, 2002, 02:44.

                Comment


                • #9
                  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?

                  Comment


                  • #10
                    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.
                    Clash of Civilization team member
                    (a civ-like game whose goal is low micromanagement and good AI)
                    web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

                    Comment


                    • #11
                      Yea, i see your point, I really like that "being cheaper" example, and yea, I'm still in college, so maybe I haven't seen it all when under pressure. (Can you tell I'm awake now and not so grouchy as last night coming home from work)... 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. ^_^

                      Comment


                      • #12
                        --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.

                        Comment


                        • #13
                          i think what he was saying was that these hard languages actually hold the real power of programming, not languages that let you take the easy way out IE--VB(what will you actually learn from it hehehe?). umm.... than again, who ever said that if you work hard you'll reap great benefits? BTW, i highly doubt the Doc is a moron. 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. 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... In the meantime allow those morons like Doc to learn their assembly code and C++ code so they can help develop Java.

                          Comment


                          • #14
                            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.

                            Comment


                            • #15
                              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*
                              Better to be wise for a second than stupid for an entire lifetime.

                              Creator of the LWC Mod for Civ3.

                              Comment

                              Working...
                              X