1 / 49

The Myths (and Truths) of Java Games Programming

The Myths (and Truths) of Java Games Programming. Andrew Davison Dept. of Computer Engineering Prince of Songkla University Hat Yai, Songkhla 90112 Thailand ad@fivedots.coe.psu.ac.th. In a Nutshell. Java for games programming: are you joking? No, Java is a great games programming language.

jangle
Télécharger la présentation

The Myths (and Truths) of Java Games Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Myths (and Truths) of Java Games Programming Andrew Davison Dept. of Computer EngineeringPrince of Songkla UniversityHat Yai, Songkhla 90112Thailand ad@fivedots.coe.psu.ac.th

  2. In a Nutshell • Java for games programming: are you joking? • No, Java is a great games programming language.

  3. The Familiar Advantages • The object-oriented paradigm. • Cross-platform support. • Code reuse. • Ease of development. • Tool availability. • Reliability and stability. continued

  4. Good documentation. • Support from Sun Microsystems. • Low development costs. • The ability to use legacy code (e.g. C, C++) • Increased programmer productivity. • It's fun, especially for games programming.

  5. Java Bashing • Java is too slow for games programming. • Java has memory leaks. • Java is too high-level. • Java application installation is a nightmare. • Java isn't supported on games consoles. • No one uses Java to write 'real' games. • Sun Microsystems isn't interested in supporting Java gaming. • Almost all of these are substantially wrong.

  6. Wake up, it's 2006 • These objections had more validity in the late 1990s • the language and its libraries were less sophisticated and slower • lots of hype led to lots of disappointment

  7. 1. Java Is Too Slow For Games Programming • Or "Java is slow compared to C and C++, the dominant languages for games programming at the moment." • JDK 1.0 (1996): 20 to 40 times slower than C++ • J2SE 5: only 1.1 times slower • Java SE 6 is about 20% faster than J2SE 5 continued

  8. Speed depends on the application and coding style • Java programmers must be good programmers • Jack Shirazi's Java Performance Tuning site • http://www.javaperformancetuning.com/

  9. The Hotspot Compiler • Introduced in J2SE 1.3. • The run-time system identifies areas of code that are utilized many times, and aggressively compiles them. • Program execution is often slow at the beginning until the code has been analyzed and compiled • splash screens API in Java SE 6

  10. Slow-Moan 1: Swing is Slow • Swing GUI components don't use the OS much • portability, controllablilty • extra layer of processing above OS • Some games applications use the older, lower-level AWT GUI libraries. continued

  11. J2SE 5/6 Swing uses OpenGL/DirectX more directly • Most games don't require complex GUIs • full-screen game play with mouse and keyboard controls is the norm • mouse and keyboard processing is dealt with by the AWT • full-screen mode

  12. Slow-Moan 2: my Program is Slow (because of Java) • Where to lay the blame? • graphics rendering: OpenGL or DirectX • network games: the network

  13. 2. Java Has Memory Leaks • Uhh? • Java doesn't offer pointer arithmetic • out-of-bounds array accesses are caught

  14. Possible Meaning 1 • Defunct objects are not being garbage collected. • Due to bad programming style • the garbage collector can only do its job when an object is completely dereferenced

  15. Possible Meaning 2 • Garbage collector is executing at poorly timed intervals. • The JVM comes with several different garbage collectors • can be selected/fine-tuned from the command line

  16. Profiling Tools • Java SE 6: jps, jstat, jhat, and jstack • Many third-party tools • e.g. JProfiler

  17. 3. Java Is Too High-level • Abstraction versus speed and control • C++ is too high-level • C is too high-level • assembler is too high-level • ICs are too high-level • an abacus is sufficientfor all our computingneeds

  18. Historical Observation • The gaming community used to think that C and C++ were too high-level. Until: • Doom and Dungeon Master, mid 1980s • cross-platform development tools • e.g. RenderWare, Gamebryo

  19. High-level Moan 1 • Java’s use of classes, objects, and inheritance add too much overhead without enough coding benefit. • Class libraries are essential: • high-speed I/O, advanced 2D and 3D graphics, networking, etc. • Object-oriented design (UML)

  20. High-level Moan 2 • Low-level, fast operations -- such as direct Video RAM I/O -- are impossible. • Full-screen mode • page flipping • control over the screen's resolution and image depth • Graphics rendering using OpenGL and DirectX.

  21. High-level Moan 3 • Java can't use game peripherals • e.g. joysticks and game pads • Yes it can: • JNI, the Java Native Interface • JInput, the game devices API • https://jinput.dev.java.net/

  22. 4. Installation Is A Nightmare • Java has to be on the machine before the application will run. • Code bloat • even small programs require a 16 MB JRE • Frequently changing JVMs. • Non-standard components are often required (e.g. Java 3D). continued

  23. It's not possible to compile the application for a specific platform. • The .jar extension is hijacked by other software • The JRE is slower to start up compared to a native compiled application. • Solved with good installation software • except for 2 and 7

  24. Many Installation Options • Applets • Java SE 6 plug-in • for Internet Explorer • Java Web Start (JWS) • improved significantly since J2SE 1.4. • Third-party installers • e.g. install4j

  25. Code Bloat • Increasingly irrelevant • many games weighing in at over 100 MB • many graphics and sound card drivers are larger than 15 MB • Network speeds are a problem, especially overseas • broadband usage is growing rapidly

  26. Others • Sun Microsystems estimates that around 70% of all new PC's come with a JRE pre-installed. • Slow start-up time, but • better in Java SE 6 • fairly negligible compared to the total running time • Java SE 6's splash screen API

  27. 5. Java Isn't Supported On Games Consoles • This criticism has some justification. • Two important games platforms: • the PS2 and Windows • Java isn't available on the PS2 continued

  28. Actually it is possible to run Java on the PS2 using Sony's version of Linux, but: • the OS requires the PS2 to have a hard disk • only limited access to hardware • Two trends that may help Java: • consoles are mutating into home media devices • the rise of online gaming

  29. Java on the PS3? Probably Not • Basic/premium PS3 versions will have • 512 MB of RAM, a large hard drive,Linux support, OpenGL • Casual games programming on the PS3 • development kits in Spring 2007 • support for an object-oriented language • probably C++/C • virtual machine utilizes JIT technology

  30. Blu-ray Drives • Support a version of Java called BD-J for: • interactive menus, GUIs • networking applications

  31. Other Markets • The PC market is far from miniscule • US$ 953 million by the end of 2008 • over a billion in 2009 • Games on PCs • superior, modern hardware • video cards, RAM, internet connections • more exciting game play • many more PC games, particularly in the area of multiplayer online games continued

  32. Mobile gaming • sales rising to US$ 2.5 billion in 2007 • thought to be around 250 million Java-enabled phones • Java ME

  33. 6. No One Uses Java To Write Real Games • The number of commercial Java games is small, but growing • won awards and bestsellers • e.g. Tribal Trouble, Puzzle Pirates, Call of Juarez, Chrome, Titan Attacks, Star Wars Galaxies, Runescape, Alien Flux, Kingdom of Wars, Law and Order II, Ultratron, Roboforge, IL-2 Sturmovik, Galactic Village, Wurm Online, ... continued

  34. Casual Gaming Market • Java is used widely in the casual gaming market • game play is more innovative • implementation timelines are shorter • budgets smaller • less man-power needed • By 2008, the casual games market will surpass US$2 billion in the US.

  35. Many Java Gaming Sites • Sun Microsystems showcase • http://www.java.com/en/games/ • Community pages • http://community.java.net/games/ • Open-source gaming tools • https://games.dev.java.net/ continued

  36. The Java Games factory • http://javagamesfactory.org/ • Works-in-progress • https://games-forge.dev.java.net/ • JavaGaming forums • http://www.javagaming.org/

  37. JavaGaming.org • Best source of technical advice • over 9000 highly opinionated registered users • Discussion topics • Java 3D, Java 2D, Java Sound, J2ME, networking, online games development, performance tuning, JOGL, JOAL, JInput, and more

  38. Open-source Gaming Tools https://games.dev.java.net/ • JOGL, a Java binding for OpenGL • JOAL, a binding for OpenAL (a 3D audio library) • JInput, a game devices API • games-middleware and games-forge sections

  39. Books continued

  40. due out in May 2007 http://fivedots.coe.psu.ac.th/~ad/jg

  41. 7. Sun Isn't Interested • J2SE 1.3 • improved graphics and audio capabilities • Version 1.4 • full-screen mode and page flipping in hardware • faster I/O, memory mapping • support for non-block sockets • useful in client/server multiplayer games continued

  42. Version 5.0 • nanosecond timer • Java extension libraries, e.g. • Java 3D • JMF (the Java Media Framework) • the Java Communications API • JAXP (Java’s peer-to-peer API) continued

  43. Java SE 6 • improved graphics rendering speeds • splash screen API, scripting, desktop API • Sun-sponsored websites • http://www.javagaming.org • http://www.java.net • http://community.java.net/games/

  44. Sun's Project DarkStar http://games-darkstar.dev.java.net • Tools for supporting massive multi-player online games. • server side: Sun Game Server (SGS) • client APIs for C++, Java SE, and Java ME

  45. 8. In a Nutshell • Java for games programming: are you joking? • No, Java is a great games programming language.

More Related