Java for real-time applications

This is a discussion on Java for real-time applications within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Anyway, please excuse the poor title choice but my post does cover several things. Since there are a lot of ...

  1. #1
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459

    Java for real-time applications

    Anyway, please excuse the poor title choice but my post does cover several things.

    Since there are a lot of C++ programmers on here (who, stereotypically hate java) I thought I'd ask...

    Background: I've been playing around with C for a couple of years, currently almost at the end of my first of four years in a Software Engineering degree having only used Java since the start of 2008. And getting rather competent in it, possibly thanks to my C background.

    I've been reading several real-time application development books, some game related, others not -- in this context by real-time I mean things like games etc. Since I've only really played around with C++ for a little while, I can easily read it and reproduce it just there are some several 'dark areas' I'd need to brush up on. I've decided to try make some sort of 3D game engine in Java ... for those of you who have used Java you'll notice how much you get for how little typing you do!

    I've also looked in to various benchmarks of C/C++ vs Java. And I've looked at the quake2 Java re-write "jake2". I just love the fact it's portable, and that I don't have to do anything for some platform I've never heard of to play! Granted some JVM emulation to ensure consistancy (such as floats) is going to incur a speed cost as are JNI calls to OpenGL. It should also be taken into account that computer horseys are getting cheaper, and this would definatly not be class as "industrial grade" by todays standards.

    Basically I want peoples' thoughts/ideas, such as potential security or performance issues (I've been benchmarking various style of Java coding such as static methods vs instance methods -- the results are a surprise!)... and things I might need to watch for. Sorry for the long post

    I've attached the first iteration of the class diagram (sorry it's hard to read, the diagram is rather big dimension wise and had to be scaled back) , still a lot of classes to add; including various spatial partitioning -- so far an Octree but further research / reading could change that. It's not complete, comments on that as well as the diagram itself (part of my coursework) are appreciated! Note the shaded areas are the 'binaries' where execution starts (2 binaries).
    Attached Images Attached Images  
    Last edited by zacs7; 08-25-2008 at 06:41 AM.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Obviously, each persons thoughts of what "real-time" is and what it should encompass. There is certainly a possibility to use Java for some things that can be considered Real-Time (such as games - they are hardly what I would call "Hard Realtime").

    Designing applications in Java or C++ for real-time is more a case of using appropriate algorithms and make sure that you make the best possible use of the system, than a consideration of what language is being used. As we all know, 90% of the code corresponds to 10% of the exucution time, and 10% of the code does 90% of the execution time. So making sure you do the right things in those 10% of the code is the key to making it run fast, not what you do (or what language you use) in the other 90%.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    Java has come far enough that you can use it for games, as long as you're not on the cutting edge of technology.

    However, "real-time" is usually used for applications that have hard deadlines to meet, typically in controller systems.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by CornedBee View Post
    However, "real-time" is usually used for applications that have hard deadlines to meet, typically in controller systems.
    Yes, in my world, if it doesn't got horribly wrong when you miss a deadline by a few hundred microseconds, it's not a "proper" real-time system. I think the most strict system I worked on (which by no means is any record in that area) had an interrupt that had to be taken and 60 microseconds worth of caclulations completed within 100 microseconds before things would start going wrong. If we missed a deadline of 160 microseconds from interrupt going active, the system would reboot. Windows (probably not even WinCE) or Linux [at least without real-time extensions] wouldn't stand a chance in that scenario.

    Worst part was that some programmers tried to use floating point calculations (on an integer only processor), and the floating point emulation library would disable interrupts [for valid reasons in itself - they used some special registers in the processor that was customarily used for interrupt and trap handling] - so a large amount of time was spent hunting down calls to the FP emulation to avoid those things. Also there were pieces of code that disabled and enabled interrupts here and there - again, some programmers had little idea of how long something would take, and disabled interrupts for far longer than was a good idea in such a system.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Jun 2008
    Posts
    266
    I would like to point out the game runescape which is actually written in java and my little cousin is crazy about that game. The game doesn't have the best graphics but it is still quite popular. I could see a game written in java a better light mmorpg than I could a CPU intense first-person shooter.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Representing floats with color?
    By DrSnuggles in forum C++ Programming
    Replies: 113
    Last Post: 12-30-2008, 08:11 AM
  2. Using pointers
    By Big_0_72 in forum C Programming
    Replies: 3
    Last Post: 10-28-2008, 07:51 PM
  3. Read and set\change system time
    By Hexxx in forum C++ Programming
    Replies: 9
    Last Post: 01-02-2006, 06:11 AM
  4. The Timing is incorret
    By Drew in forum C++ Programming
    Replies: 5
    Last Post: 08-28-2003, 04:57 PM
  5. relating date....
    By Prakash in forum C Programming
    Replies: 3
    Last Post: 09-19-2001, 09:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21