Optimization for free

Discussion in 'Game Development (Technical)' started by princec, Jan 30, 2006.

Thread Status:
Not open for further replies.
  1. Vorax

    Original Member

    Joined:
    Jan 21, 2005
    Messages:
    349
    Likes Received:
    0
    The problem with these kind of threads is that always start off harmless, but they are eventually read as:

    "I am a god of programming because I use Java! I know the one true way!! You are all freaking idiots!!! C++ suxors - Java roxors!!! Praise Jaba Praise Jaba! Ohhmmm"

    When the original point was simply:

    "Javagaming.org thread about a GamaSutra article on games optimisation. Basic story: about half the optimisations given in the article are given for free in the Java/.net world. Just a morsel for thought.
    "

    It's always fun to watch the evolution :D
     
  2. HairyTroll

    Original Member

    Joined:
    Jul 29, 2004
    Messages:
    582
    Likes Received:
    0
    But that morsel gave half the members of this forum severe indigestion.
     
  3. Vorax

    Original Member

    Joined:
    Jan 21, 2005
    Messages:
    349
    Likes Received:
    0
    If this is a requirement in a Java program, you would have the class implement (as in the java key word, not the act of writing the code) the interface that you want the object to mute into at run-time and have the object collaborate.
    A implements B, but delegates to a concrete B.
    A has no code for the funcionality of B, but everything that talks to it is none the wiser and they can call it an A by name.
    A also contains the concrete methods originally defined of A with purpose.
    B could do the same to act like A, or any other class.

    Of course, if you need to do anything beyond that, you have a potential rats nest of issues anyway as the size and complexity of the program grows. Bottom line is, you have designed your code wrong.

    At least one other language allows you to hack around that and will even claim it's a feature ;)

    You can change code at run-time in the debugger in Java, without stopping. If you change the method signature or you change the signature of one of the active stack methods, you will have to stop and restart. Java can run-time replace objects with new code. It's done in J2EE application servers all the time for hot deployment of Java applications (while the user is running it, it's patched).

    CORRECTION: You can't change the method that's executing unless you are running as interrpreted (BeanShell), only other methods in the same class.

    Hmm.... I smell Lisp here ;) Get your own thread going so it can take it's own proper beating!! Hehehe
     
    #83 Vorax, Feb 3, 2006
    Last edited: Feb 3, 2006
  4. HairyTroll

    Original Member

    Joined:
    Jul 29, 2004
    Messages:
    582
    Likes Received:
    0
    Since Epic has been discussed in this forum, it's probably appropriate to post a link to a presentation by Tim Sweeney of Epic discussing his thoughts on the requirements for the next generation of programming languages.
     
  5. Fabio

    Original Member

    Joined:
    Sep 30, 2005
    Messages:
    499
    Likes Received:
    0
    Of course not, but if you were saying "pencil is a waste of time" almost every thread and, to make your gfx, simply ran an app and rendered the demo project, then I'd think you were a bit less artist. Which is not bad per se (rather, it's VERY SMART), but when, in that situation, you hypotetically labeled those that use a pencil as "dinosaurs", someone may have to rebel.

    I enjoy programming, but that doesn't make me productive. What makes me productive is that, because I enjoy programming, I've invested many of my years into developing my own "set of classes" (I prefer to call them "modules"), and thus now building an app for me is more like linking together the required modules, which I know better than my pockets, and which I'd never exchange for this mess nor for that mess.

    If I HAD TO (but why?) start from zero, of course Java or C# with their "rich classes" would be tons more productive than "out of the box" C (or even C++ STL). But who said that we've to compare the bones of C with the full power of Java? Most experienced programmers have their own tons of modules anyway, so does it make ANY sense to switch to Java? Does it really give any advantage? Look at Kestral's reply, for example. And it annoys me much to be labeled "granny" in a arrogant way by my Java nephews. Young ones don't respect oldies anymore.. ;)
     
  6. Fabio

    Original Member

    Joined:
    Sep 30, 2005
    Messages:
    499
    Likes Received:
    0
    And, I add, most unexperienced programmers that want to become experienced ones, better build their own modules. Then and only then they'll have to face if it's the case to switch to STL or Java or C#, etc.. because they couldn't, in the end, produce anything better. But to start with STL, Java or C# is quite cutting your wings by yourself, IMHO. Unless it's only business for you..
    I've known 4 Java programmers (degree and near degree) that failed, all four in a row, all four getting the help of each other, the damn simple task to write few lines of code to convert in place from RGB to BGR a portion of an image. When I sat down and wrote (in Java) the code and typed it at the speed of my fingers, they were all shocked. But I was shocked more than them. That was a trivial task to say the least. I'd never hire such university geniouses.. I'd rather hire my brother who only knows VIC20 BASICV2.
     
  7. Fabio

    Original Member

    Joined:
    Sep 30, 2005
    Messages:
    499
    Likes Received:
    0
    Me too have published (retail) games, the only Amiga games I know of that reach 50fps doing texture mapping on a vanilla, unexpanded A1200. Also, about being "close minded" like many of you label us "oldies" (I'm just 31 years old anyway..), consider that my (retail, thus big project) games took about 9 months to be developed, and they all were almost a one-man project, and had something like 3% of assembly (while I was a big advocator of assembly, I had my own programming language to be productive, HLA).
    And I had enough of the aggressivity I see in these threads that I wanted to speak, for one time.

    Which assumes that I'm not?

    Gosh! you don't have to rewrite the same code 1000 times.. did you ever hear about "code reuse"? You can rewrite the same code 1000 times even in Java or C#, for what it's worth.
    Every language has its pro and cons, like every tool on Earth. But it's not me - it's Cas & Co - who is being aggressive towards the rest (or who started it and reiterated it many times), by affirming that Java is better than the rest for EVERY practical thing, or by implying that. Otherwise I don't understand Cas commitment in his old cause.
     
    #87 Fabio, Feb 3, 2006
    Last edited: Feb 3, 2006
  8. Fabio

    Original Member

    Joined:
    Sep 30, 2005
    Messages:
    499
    Likes Received:
    0
    Hi! I fully respect your opinion, and can live perfectly with it. I too like to concentrate on the design of the game (that's one of the reasons why I made my modules, after all), and what you wrote doesn't contraddict anything, IMHO.

    I mean, I've nothing against who decides to use Java or C#. What really annoys me is when those same people repeat one thread yes and one thread no that they are doing the right thing and whoever uses C++ / C or even worse ASM (be it pure or even a small percentage of the total code) is wasting his time. I find this very annoying, expecially because it's a recurring annoyance.

    So that's the only problem. When I developed Amiga games, before I made my own programming language, I was coding my tools in AMOS (a kind of BASIC). I'd have never developed my tools, editors, etc.. in ASM, it just made no sense. But those that try to enforce at every other thread their opinions are expressing an aggressive attitude, IMHO, which sooner or later may piss some grannies like me and enforce an equally aggressive reply.

    That's all. CODE AND LET CODE.
     
    #88 Fabio, Feb 3, 2006
    Last edited: Feb 3, 2006
  9. Fabio

    Original Member

    Joined:
    Sep 30, 2005
    Messages:
    499
    Likes Received:
    0
    Touchet!

    "Ranting against clones" syndrome is such a crippling disease. I wish more designers would wake up.
     
  10. Fabio

    Original Member

    Joined:
    Sep 30, 2005
    Messages:
    499
    Likes Received:
    0
    Well.. at least I'm not alone. An excerpt from this page that I suggest to read in full, anyway:
    As long as there will be an advantage in designing CPUs the way they are today (and yesterday, and most probably also tomorrow although CPUs get designed more and more to suit the HLL needs), there will be a distinct advantage in knowing how they work, to then apply this knowledge as far as one wants (from ASM to BASIC).
    While I think Java may be the perfect choice for a big quantity of situations, what I can't stand is those that think to be universally smarter than who sticks with his own tools and modules, instead of embracing Bill's C# and .NET or other "I do it for you" smart solutions.
    Java is not as productive as Cas says. BASIC gets the job done in less time, so if that is what counts (regardless of the final result of "job"), then BASIC should be a better answer than Java. Yet anyone saying that BASIC is always better than Java because "it gets the job done in less time" would be a fool. There's so much more than that in computer science.. even in game business.
     
  11. Fabio

    Original Member

    Joined:
    Sep 30, 2005
    Messages:
    499
    Likes Received:
    0
    The ridicolous part is that it's the gfx card hardware that is doing the REAL work anyway.

    What about: would you write a modern OS kernel in Java or C#? :D
    While not many of us would care to write a modern OS kernel anyway, that is an example of how wrong is "Java/C# gets [any] job done, and in less time". Clearly there's something wrong..
    And I also don't understand all this hate against pointers. But anyway..
     
  12. g666

    Original Member

    Joined:
    Dec 23, 2005
    Messages:
    14
    Likes Received:
    0
    Good point. Use what you like. just dont try and fanatically force it on others.:D
     
  13. g666

    Original Member

    Joined:
    Dec 23, 2005
    Messages:
    14
    Likes Received:
    0
    Duck.:eek:
     
  14. Fabio

    Original Member

    Joined:
    Sep 30, 2005
    Messages:
    499
    Likes Received:
    0
    I think that where Metaprogramming and Aspect Oriented Programming, while having merits, fail in the end is the presumption to be the solution for all problems, the "formula" for programming, by extending abstraction.
    The perspective I like to use for programming instead is the very opposite: start from who actually does the job (the CPU), and then automatize everything that a machine can do better than a human (many compiler jobs), and grow the system from there, extending it more and more, but never losing the lowlevel vision, because everything returns there in the end.
    Thus I clap advanced preprocessors (like those adding OOP functionality to a language, or templates), which ease otherwise tedious, mechanical and uncreative/unproductive work. I clap backend optimizers, and anything that makes you more productive without forcing you away from the "truth" (the lowlevel of things).
    Abstraction is a powerful and elegant tool, but is also the reason why most programs and programmers are far from being efficient nowadays. You should never lose the view of the inside, even if the tools get better and better every day, in the end is still the CPU that executes the code, and if you don't understand how the pipeline or the caches work, you CANNOT write really good code.
    I can perfectly live with "and who cares to write really good code? I want it just to run", but please do not say that you're right and those that instead give merits to efficient code are old, boring and wrong. It would be paradoxical to say the least.

    You may have noticed that this was THE VERY FIRST TIME I joined a thread about "this language sucks, that other rocks". I just had it enough to read that who uses C++ is an imbecile, because it's the most stupid thing I could read, and when I read it every other thread it starts to really piss me.

    Let me say it again: CODE AND LET CODE.
     
  15. Savant

    Original Member

    Joined:
    Feb 8, 2005
    Messages:
    1,674
    Likes Received:
    0
    To do what? Drink? ;)
     
  16. Savant

    Original Member

    Joined:
    Feb 8, 2005
    Messages:
    1,674
    Likes Received:
    0
    Unless you are writing device drivers or trying to squeeze your application onto a mobile device, there is zero reason to get involved in the nuts and bolts these days. Programmers in the old days didn't know assembly and the raw Win32 Windows API because they wanted to - they knew those things because that was the most efficient way to get things done at that time. There was no other way.

    Understanding the CPU pipeline and caches and all that sort of bunk is pointless as that's what the compiler should be doing for me. Unless you're writing a low level, high performance engine or library, it's time wasted that could be spent designing classes or making your game fun. That's what the CLR is all about - Microsoft can update and optimize the hell out of that, while my code remains the same. That's the path to the future.

    These days, the most efficient way to code is to use something like Java/C# and high level libraries like .NET. Clinging to these old ideals sounds a lot like a "Back in MY day..." style rant and it's a little sad.
     
  17. princec

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    4,873
    Likes Received:
    0
    Yep. It's a tiny miracle :) (There's more to a VM than DLLs by the way... there's loads of stuff in there to do networking and remote server calls and SSL and so on. It could be further optimised by maybe another half a meg but I really can't be bothered - the game is already tiny)

    Cas :)
     
  18. EJSainz

    Original Member

    Joined:
    Nov 23, 2005
    Messages:
    140
    Likes Received:
    0
    Well, maybe they'll start yet another PC vs Mac fight. I hope not :D - it's so tiring :D:D .
     
  19. Fabio

    Original Member

    Joined:
    Sep 30, 2005
    Messages:
    499
    Likes Received:
    0
    Really? Like if you've to perform some computing on two or more very big arrays, doing it in chunks that fit into the cache or doing it in one single block WILL make a HUGE difference in performance and there's no compiler that will rewrite that code for you.

    Microsoft is well known historically for the low quality of its programmers (juding by the results at least), although the company has all the economical means to hire the best programmers in the world and make good use of them (notably, the lone VC is a great application, IMHO).
    Putting yourself in the hands of Microsoft is committing the worst kind of suicide, IMHO. And not only because their code quality historically has always been the worst of the industry, but also because the company's policy and all sucks.

    Efficient for who? For a newbie with zero experience? YES (blame the lack of a serious standard library for C, expecially for audio/video/input, but we got OpenGL and OpenAL anyway). Or for someone that has written and perfectioned his own modules for 10+ years (let away the previous 10 years he has spent in actually learning all the theory behind them)?

    Do you realize that there are people - even on this board - that are already very productive with their own modules? Do you realize that a switch to C# and .NET for them would only have disadvantages?

    Do you realize that games' clones are the future? ;)
     
  20. Fabio

    Original Member

    Joined:
    Sep 30, 2005
    Messages:
    499
    Likes Received:
    0
    My favourite was "hey! my Atari ST is heavier than your Amiga 500!".. those were great times.. :D
     
Thread Status:
Not open for further replies.

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer