C Board  

Go Back   C Board > Community Boards > General Discussions

Reply
 
LinkBack Thread Tools Display Modes
Old 08-25-2008, 06:33 AM   #1
Woof, woof!
 
zacs7's Avatar
 
Join Date: Mar 2007
Location: Australia
Posts: 3,297
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
 
__________________
"I.T. gets the chicky-babes" - M. Kelly
bakefile | vim

Last edited by zacs7; 08-25-2008 at 06:41 AM.
zacs7 is offline   Reply With Quote
Old 08-25-2008, 06:46 AM   #2
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
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.
matsp is offline   Reply With Quote
Old 08-25-2008, 08:12 AM   #3
Cat without Hat
 
CornedBee's Avatar
 
Join Date: Apr 2003
Posts: 8,492
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
CornedBee is offline   Reply With Quote
Old 08-25-2008, 12:30 PM   #4
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
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.
matsp is offline   Reply With Quote
Old 08-26-2008, 06:34 AM   #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.
lruc is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 01:31 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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