Post on 09-Jan-2016
description
Myths 1
The Myths (and Truths) of Java The Myths (and Truths) of Java Games ProgrammingGames Programming
Andrew DavisonAndrew Davison
Dept. of Computer EngineeringDept. of Computer EngineeringPrince of Songkla UniversityPrince of Songkla University
Hat Yai, Songkhla 90112Hat Yai, Songkhla 90112ThailandThailand
ad@fivedots.coe.psu.ac.th
Myths 2
In a NutshellIn a Nutshell
Java for games programming: are you Java for games programming: are you joking? joking?
No, Java is a great games programming No, Java is a great games programming language.language.
Myths 3
The Familiar AdvantagesThe Familiar Advantages
The object-oriented paradigm.The object-oriented paradigm. Cross-platform support.Cross-platform support. Code reuse.Code reuse. Ease of development.Ease of development. Tool availability.Tool availability. Reliability and stability.Reliability and stability.
continued
Myths 4
Good documentation.Good documentation. Support from Sun Microsystems.Support from Sun Microsystems. Low development costs.Low development costs. The ability to use legacy code (e.g. C, C++)The ability to use legacy code (e.g. C, C++) Increased programmer productivity.Increased programmer productivity.
It's It's funfun, especially for games programming., especially for games programming.
Myths 5
Java BashingJava Bashing
1.1. Java is too slow for games programming.Java is too slow for games programming.
2.2. Java has memory leaks.Java has memory leaks.
3.3. Java is too high-level.Java is too high-level.
4.4. Java application installation is a nightmare.Java application installation is a nightmare.
5.5. Java isn't supported on games consoles.Java isn't supported on games consoles.
6.6. No one uses Java to write 'real' games.No one uses Java to write 'real' games.
7.7. Sun Microsystems isn't interested in supporting Java Sun Microsystems isn't interested in supporting Java gaming.gaming.
Almost all of these are substantially wrong. Almost all of these are substantially wrong.
Myths 6
Wake up, it's 2006Wake up, it's 2006
These objections had more These objections had more validity in the late 1990svalidity in the late 1990s– the language and its libraries the language and its libraries
were less sophisticated and were less sophisticated and slowerslower
– lots of hype led to lots of disappointmentlots of hype led to lots of disappointment
Myths 7
1. Java Is Too Slow For 1. Java Is Too Slow For Games ProgrammingGames Programming
Or "Java is slow compared to C and Or "Java is slow compared to C and C++, the dominant languages for C++, the dominant languages for games programming at the moment." games programming at the moment."
JDK 1.0 (1996): 20 to 40 times slower than JDK 1.0 (1996): 20 to 40 times slower than C++C++
J2SE 5: only 1.1 times slowerJ2SE 5: only 1.1 times slower Java SE 6 is about 20% faster than J2SE 5 Java SE 6 is about 20% faster than J2SE 5
continued
Myths 8
Speed depends on the application Speed depends on the application and coding styleand coding style– Java programmers must be good programmersJava programmers must be good programmers
Jack Shirazi's Java Performance Tuning siteJack Shirazi's Java Performance Tuning site– http://www.javaperformancetuning.com/http://www.javaperformancetuning.com/
Myths 9
The Hotspot CompilerThe Hotspot Compiler
Introduced in J2SE 1.3.Introduced in J2SE 1.3. The run-time system identifies areas of code that The run-time system identifies areas of code that
are utilized many times, and aggressively are utilized many times, and aggressively compiles them. compiles them.
Program execution is often slow at the beginning Program execution is often slow at the beginning until the code has been analyzed and compiled until the code has been analyzed and compiled – splash screens API in Java SE 6splash screens API in Java SE 6
Myths 10
Slow-Moan 1: Swing is SlowSlow-Moan 1: Swing is Slow
Swing GUI components don't use Swing GUI components don't use the OS muchthe OS much– portability, controllabliltyportability, controllablilty– extra layer of processing above OSextra layer of processing above OS
Some games applications use the older, Some games applications use the older, lower-level AWT GUI libraries.lower-level AWT GUI libraries.
continued
Myths 11
J2SE 5/6 Swing uses OpenGL/DirectX more J2SE 5/6 Swing uses OpenGL/DirectX more directlydirectly
Most games don't require complex GUIsMost games don't require complex GUIs– full-screen game play with mouse and keyboard full-screen game play with mouse and keyboard
controls is the normcontrols is the norm
– mouse and keyboard processing is dealt with by the mouse and keyboard processing is dealt with by the AWTAWT
– full-screen modefull-screen mode
Myths 12
Slow-Moan 2: my Program is Slow Slow-Moan 2: my Program is Slow (because of Java)(because of Java)
Where to lay the blame?Where to lay the blame?– graphics rendering: OpenGL or DirectXgraphics rendering: OpenGL or DirectX– network games: the networknetwork games: the network
Myths 13
2. Java Has Memory Leaks2. Java Has Memory Leaks
Uhh?Uhh?– Java doesn't offer pointer arithmeticJava doesn't offer pointer arithmetic– out-of-bounds array accesses are caughtout-of-bounds array accesses are caught
Myths 14
Possible Meaning 1Possible Meaning 1
Defunct objects are not Defunct objects are not being garbage collected.being garbage collected.
Due to bad programming styleDue to bad programming style– the garbage collector can only do its job when the garbage collector can only do its job when
an object is completely dereferencedan object is completely dereferenced
Myths 15
Possible Meaning 2Possible Meaning 2
Garbage collector is executing at Garbage collector is executing at poorly timed intervals.poorly timed intervals.
The JVM comes with several different The JVM comes with several different garbage collectorsgarbage collectors– can be selected/fine-tuned from the command can be selected/fine-tuned from the command
lineline
Myths 16
Profiling ToolsProfiling Tools
Java SE 6Java SE 6: : jps, jstat, jhat, and jstackjps, jstat, jhat, and jstack
Many third-party toolsMany third-party tools– e.g. JProfiler e.g. JProfiler
Myths 17
3. Java Is Too High-level3. Java Is Too High-level
Abstraction versus speed and controlAbstraction versus speed and control– C++ is too high-levelC++ is too high-level– C is too high-levelC is too high-level– assembler is too high-levelassembler is too high-level– ICs are too high-levelICs are too high-level
– an abacus is sufficientan abacus is sufficientfor all our computingfor all our computingneedsneeds
Myths 18
Historical ObservationHistorical Observation
The gaming community used to think that C The gaming community used to think that C and C++ were too high-level. Until:and C++ were too high-level. Until:– Doom and Dungeon Master, mid 1980sDoom and Dungeon Master, mid 1980s– cross-platform development toolscross-platform development tools
e.g. RenderWare, e.g. RenderWare, GamebryoGamebryo
Myths 19
HighHigh--level Moan 1level Moan 1
Java’s use of classes, objects, Java’s use of classes, objects, and inheritance add too much and inheritance add too much overhead without enough coding benefit.overhead without enough coding benefit.
Class libraries are Class libraries are essentialessential::– high-speed I/O, advanced 2D and 3D graphics, high-speed I/O, advanced 2D and 3D graphics,
networking, etc.networking, etc. Object-oriented design (UML)Object-oriented design (UML)
Myths 20
HighHigh--level Moan 2level Moan 2 Low-level, fast operations -- such as direct Low-level, fast operations -- such as direct
Video RAM I/O -- are impossible.Video RAM I/O -- are impossible.
Full-screen modeFull-screen mode– page flippingpage flipping– control over the screen's resolution and image depthcontrol over the screen's resolution and image depth
Graphics rendering using OpenGL and DirectX.Graphics rendering using OpenGL and DirectX.
Myths 21
HighHigh--level Moan 3level Moan 3
Java can't use game peripheralsJava can't use game peripherals– e.g. joysticks and game padse.g. joysticks and game pads
Yes it can:Yes it can:– JNI, the Java Native InterfaceJNI, the Java Native Interface– JInput, the game devices API JInput, the game devices API
https://jinput.dev.java.net/https://jinput.dev.java.net/
Myths 22
4. Installation Is A Nightmare4. Installation Is A Nightmare
1.1. Java has to be on the machine before the Java has to be on the machine before the application will run.application will run.
2.2. Code bloatCode bloat– even small programs require a 16 MB JREeven small programs require a 16 MB JRE
3.3. Frequently changing JVMs.Frequently changing JVMs.
4.4. Non-standard components are often Non-standard components are often required (e.g. Java 3D).required (e.g. Java 3D).
continued
Myths 23
5.5. It's not possible to compile the application for a It's not possible to compile the application for a specific platform. specific platform.
6.6. The .jar extension is hijacked by other softwareThe .jar extension is hijacked by other software
7.7. The JRE is slower to start up compared to a The JRE is slower to start up compared to a native compiled application.native compiled application.
Solved with good installation softwareSolved with good installation software– except for 2 and 7except for 2 and 7
Myths 24
Many Installation OptionsMany Installation Options
Applets Applets Java SE 6 plugJava SE 6 plug--inin
– for Internet Explorerfor Internet Explorer Java Web Start Java Web Start ((JWSJWS))
– improved significantly since J2SE 1.4improved significantly since J2SE 1.4.. ThirdThird--party installersparty installers
– ee..gg. . install4jinstall4j
Myths 25
Code BloatCode Bloat
Increasingly irrelevantIncreasingly irrelevant– many games weighing in at over 100 MBmany games weighing in at over 100 MB– many graphics and sound card drivers are larger many graphics and sound card drivers are larger
than 15 MBthan 15 MB
Network speeds are a problem, especially Network speeds are a problem, especially overseasoverseas– broadband usage is growing rapidlybroadband usage is growing rapidly
Myths 26
OthersOthers
Sun Microsystems estimates that around 70% Sun Microsystems estimates that around 70% of all new PC's come with a JRE of all new PC's come with a JRE pre-installed.pre-installed.
Slow start-up time, butSlow start-up time, but– better in Java SE 6better in Java SE 6– fairly negligible compared to the total running timefairly negligible compared to the total running time– Java SE 6's splash screen APIJava SE 6's splash screen API
Myths 27
5. Java Isn't Supported On Games 5. Java Isn't Supported On Games ConsolesConsoles
This criticism has some justification. This criticism has some justification.
Two important games platforms: Two important games platforms: – the PS2 and Windowsthe PS2 and Windows– Java isn't available on the PS2Java isn't available on the PS2
continued
Myths 28
Actually it is possible to run Java on the PS2 Actually it is possible to run Java on the PS2 using Sony's version of Linux, but:using Sony's version of Linux, but:– the OS requires the PS2 to have a hard diskthe OS requires the PS2 to have a hard disk– only limited access to hardwareonly limited access to hardware
Two trends that may help Java: Two trends that may help Java: – consoles are mutating into home media devicesconsoles are mutating into home media devices– the rise of online gamingthe rise of online gaming
Myths 29
Java on the PS3?Java on the PS3?
Basic/premium PS3 versions will have Basic/premium PS3 versions will have – 512 MB of RAM, a large hard drive,512 MB of RAM, a large hard drive,
Linux support, OpenGL Linux support, OpenGL
Casual games programming on the PS3Casual games programming on the PS3– development kits in Spring 2007development kits in Spring 2007– support for an object-oriented languagesupport for an object-oriented language
probably C++/Cprobably C++/C
– virtual machine utilizes JIT technologyvirtual machine utilizes JIT technology
Probably Not
Myths 30
BluBlu--ray Drivesray Drives
Support a version of Java called BD-J for:Support a version of Java called BD-J for:– interactive menus, GUIs interactive menus, GUIs – networking applicationsnetworking applications
Myths 31
Other MarketsOther Markets The PC market is far from minisculeThe PC market is far from miniscule
– US$ 953 million by the end of 2008US$ 953 million by the end of 2008
– over a billion in 2009 over a billion in 2009
Games on PCsGames on PCs– superior, modern hardwaresuperior, modern hardware
video cards, RAM, internet connectionsvideo cards, RAM, internet connections
– more exciting game playmore exciting game play
– many more PC games, particularly in the area of many more PC games, particularly in the area of multiplayer online gamesmultiplayer online games
continued
Myths 32
Mobile gamingMobile gaming– sales rising to US$ 2.5 billion in 2007sales rising to US$ 2.5 billion in 2007– thought to be around 250 million Java-enabled thought to be around 250 million Java-enabled
phonesphones– Java MEJava ME
Myths 33
6. No One Uses Java To Write Real 6. No One Uses Java To Write Real GamesGames
The number of commercial Java games is The number of commercial Java games is small, but growingsmall, but growing– won awards and bestsellerswon awards and bestsellers – e.g. Tribal Trouble, Puzzle Pirates, Call of e.g. Tribal Trouble, Puzzle Pirates, Call of
Juarez, Chrome, Titan Attacks, Star Wars Juarez, Chrome, Titan Attacks, Star Wars Galaxies, Runescape, Alien Flux, Kingdom of Galaxies, Runescape, Alien Flux, Kingdom of Wars, Law and Order II, Ultratron, Roboforge, Wars, Law and Order II, Ultratron, Roboforge, IL-2 Sturmovik, Galactic Village, Wurm IL-2 Sturmovik, Galactic Village, Wurm Online, ...Online, ...
continued
Myths 34
Myths 35
Myths 36
Myths 37
Myths 38
Java is used widely in the casual gaming marketJava is used widely in the casual gaming market– game play is more innovative game play is more innovative – implementation timelines are shorterimplementation timelines are shorter– budgets smallerbudgets smaller– less man-power neededless man-power needed
By 2008, the casual games market will surpass By 2008, the casual games market will surpass US$2 billion in the US.US$2 billion in the US.
Casual Gaming MarketCasual Gaming Market
Myths 39
Many Java Gaming SitesMany Java Gaming Sites
Sun Microsystems showcaseSun Microsystems showcase– http://www.java.com/en/games/http://www.java.com/en/games/
Community pagesCommunity pages– http://community.java.net/games/http://community.java.net/games/
Open-source gaming toolsOpen-source gaming tools– https://games.dev.java.net/https://games.dev.java.net/
continued
Myths 40
The Java Games factoryThe Java Games factory– http://javagamesfactory.org/http://javagamesfactory.org/
Works-in-progressWorks-in-progress– https://games-forge.dev.java.net/https://games-forge.dev.java.net/
JavaGaming forumsJavaGaming forums– http://www.javagaming.org/http://www.javagaming.org/
Myths 41
JavaGaming.orgJavaGaming.org
Best source of Best source of technical advicetechnical advice– over 9000 highly opinionated registered users over 9000 highly opinionated registered users
Discussion topicsDiscussion topics– Java 3D, Java 2D, Java Sound, J2ME, networking, Java 3D, Java 2D, Java Sound, J2ME, networking,
online games development, performance tuning, online games development, performance tuning, JOGL, JOAL, JInput, and more JOGL, JOAL, JInput, and more
Myths 42
OpenOpen--source Gaming Toolssource Gaming Tools
JOGL, a Java binding for OpenGLJOGL, a Java binding for OpenGL JOAL, a binding for OpenAL (a 3D audio JOAL, a binding for OpenAL (a 3D audio
library)library) JInput, a game devices API JInput, a game devices API games-middleware and games-forge games-middleware and games-forge
sections sections
https://games.dev.java.net/https://games.dev.java.net/
Myths 43
BooksBooks
continued
Myths 44
http://fivedots.coe.psu.ac.th/~ad/jg
due out in May 2007
Myths 45
7. Sun Isn't Interested7. Sun Isn't Interested
J2SE 1.3 J2SE 1.3 – improved graphics and audio capabilitiesimproved graphics and audio capabilities
Version 1.4 Version 1.4 – full-screen mode and page flipping in hardwarefull-screen mode and page flipping in hardware– faster I/O, memory mappingfaster I/O, memory mapping– support for non-block socketssupport for non-block sockets
useful in client/server multiplayer gamesuseful in client/server multiplayer games
continued
Myths 46
Version 5.0Version 5.0– nanosecond timernanosecond timer
Java extension libraries, e.g.Java extension libraries, e.g.– Java 3DJava 3D– JMF (the Java Media FrameworkJMF (the Java Media Framework))– the Java Communications APIthe Java Communications API– JAXP JAXP ((Java’s peerJava’s peer--toto--peer APIpeer API))
continued
Myths 47
Java SE 6Java SE 6– improved graphics rendering speedsimproved graphics rendering speeds– splash screen API, scripting, desktop APIsplash screen API, scripting, desktop API
Sun-sponsored websitesSun-sponsored websites– httphttp://://wwwwww..javagamingjavagaming..orgorg– httphttp://://wwwwww..javajava..netnet– httphttp://://communitycommunity..javajava..netnet//gamesgames//
Myths 48
Sun's Project DarkStarSun's Project DarkStar
Tools for supporting massive multiTools for supporting massive multi--player player online games.online games.– server sideserver side: : Sun Game Server Sun Game Server ((SGSSGS))– client APIs for Cclient APIs for C++++, ,
Java SE, and Java MEJava SE, and Java ME
http://games-darkstar.dev.java.net
Myths 49
8. In a Nutshell8. In a Nutshell
Java for games programming: are you Java for games programming: are you joking? joking?
No, Java is a No, Java is a greatgreat games programming games programming language.language.