Date post: | 21-Dec-2015 |
Category: |
Documents |
View: | 222 times |
Download: | 1 times |
Chapter 3.2C++, Java, and Scripting Languages
hacked by jeffery
2
C++
C used to be the most popular language for games
Today, C++ is a popular language for game development
3
C++: Strengths
Performance Control over low-level functionality
(memory management, etc) Can switch to assembly or C when
necessary Good interface with OS + hardware
4
C++: Strengths vis-a-vis C
High-level, object-oriented High-level language features are
essential for making today's complex games
Inheritance, polymorphism, templates, and exceptions...
Strongly typed, has improved reliability compared w/ C
5
C++: Strengths
C Heritage the primary high-level language that is
backwards-compatible with C Has APIs and compiler support in
all platforms Folks know it
6
C++: Strengths
Libraries STL (Standard Template Library)
Comprehensive set of standard libraries Boost: widely used library with wide
variety of functionality Qt, Rabin, let's not forget Qt SDL, Ogre, etc. Many commercial libraries available
7
C++: Weaknesses
Too low-level Still forces programmers to deal with
low-level issues Too error-prone Attention to low-level details is overkill
for high-level features or tools Blog after Blog, game developers write
their own scripting language atop it.
8
C++: Weaknesses
Too complicated Because of its C heritage, C++ is very
complicated Long learning curve to become
competent with the language
9
C++: Weaknesses
Lacking features No reflection or introspection features No method of object serialization No native support for message passing
10
C++: Weaknesses
Slow iteration C++ is fully compiled into binary
format from source code Compiling large numbers of files is
very slow This will only become more of a
problem as games become more complex
11
C++: When to Use It?
When performance is crucial If your current code base is mostly C and
C++ If you have a lot of in-house expertise in
C++ Avoid using it for high-level code, such as
tools
12
Java and C# for Game Development
Why use Java/C#? Simplifies many C++ features Adds several useful high-level features (Java: Easy to develop for multiple
platforms) Good library support
13
Java/C# for Game Development
Performance Notably weaker than C/C++ Has improved in the last few years:
still not up to C++ level, but very close Just-In-Time compiling and HotSpot
optimizations, etc. Now has high-performance libraries Also has access to native functionality
14
Java/C# for Game Development
Platforms Well suited to downloadable and
browser-based games Dominates development on mobile,
handheld platforms, e.g. Android Possible to use in full PC games Not used (much?) in consoles
15
Java in Game Development
Commercial games using Java Downloadable games like those from
PopCap Games: Mummy Maze, etc Online card games PC games using Java as a scripting
language: Vampire: The Masquerade, Star Wars Galaxies
PC games fully written in Java: You Don't Know Jack, Who Wants to Be a Millionaire
16
C# in Game Development
Some prominent server-side and mono-based uses, e.g. SecondLife
XNA Game Studio Express Free for students/hobbyists
17
Scripting Languages + VHLLs
Why use scripting languages and very high level languages? Ease and speed of development Short iteration time Code becomes a game asset Offer additional features and are
customizable
18
Scripting Languages
Drawbacks Slow performance
Limited tool support Dynamic typing makes it difficult to
catch errors Awkward interface with the rest of the
game Difficult to implement well
19
Scripting Languages
Popular scripting languages Python, Ruby, Lisp/Scheme,... Javascript, Actionscript, etc. Custom scripting languages
UnrealScript, QuakeC, NWNScript
20
Scripting Languages
How to choose a scripting language What features do you need? What performance requirements? What debugging facilities does the
language have? On what platforms does it need to run? What resources and expertise are
available?
21
VM as Game Engine
Game engines are typically extended with scripting languages
Games are written in a mix of systems-level (C/C++), app-level (Java/C#), and interpreted code
What would VMs need in order to replace game engines??