Game Development Reference
In-Depth Information
time. See the following sidebar, “ An Error in Operator Precedence , ” for one such
instance.
An Error in Operator Precedence
What is the result of the following arithmetic operation?
30 / 5 * 3
According to one proprietary scripting language I worked with, the an-
swer is 2 . That's because the language in question incorrectly assigned
multiplication a higher precedent than division. So the preceding code
was being interpreted as follows:
30 / (5 * 3) = 2
However, because division and multiplication have equal precedent,
the expression should instead be computed as this:
(30 / 5) * 3 = 18
This particular bug persisted in the scripting language for over a dec-
ade. No one had ever mentioned the problem to the programmer in
charge of the scripting language, probably because programmers have
a tendency to add lots of parentheses to mathematical expressions.
Oncethebugwasfound,itwaseasyenoughtofix.Butit'sacautionary
tale of what can happen with a custom scripting language.
The other consideration is that established languages typically have been designed
and developed by people who are extremely knowledgeable about compiler and
virtual machine design—far more knowledgeable on the topic than most game
programmers.
But the downside is that existing scripting languages may not always be well-
suited for game applications. There may be performance or memory allocation
concerns with the way the language is designed, or it may be difficult to bridge
the code between the scripting language and the engine. A custom language, on
the other hand, can be designed such that it is optimized specifically for game us-
age—even to the point where the language has features that are very game specif-
ic, as in UnrealScript.
 
Search WWH ::




Custom Search