lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 02/09/2018 13:14, Egor Skriptunoff wrote:
Hi!

This post is a bit off-topic.

A typo in an identifier inside a config script of one unreal-engine-based
game
worsened the game AI significantly.
But it tooks five years to find the typo.
(Lua was not the scripting language that the config was written in.)


On a related note, I was recently browsing source files for a game in "The Battle for Wesnoth" open-source game engine (strategic, turn-based, fantasy-oriented). It is scripted in Lua, but it uses a DSL (WML - Wesnoth Markup Language) for campaign/scenarios definitions.

In one of the WML files of a user-defined campaign, inside a side AI definition block I read the following line (and it was repeated in 2 other spots in the code):

aggresion = 1

That, of course, is a blatant spelling mistake, but was buried deep into code written (quite well) by a probably non-English-speaking developer.

Although, as others in this thread have said, it is not possible to prevent any sort of typos, it would help, IMO, running the code through a spell-checker.

This would help significantly, especially if one sticks to identifiers written in plain english, with component words spelled out clearly (underscores as spaces or CamelCase - of course we would need a specially configured spell-checker for this).

Although C tradition goes against this, I think that in scopes longer than about 10-15 lines using very short (or abbreviated) identifiers is usually a very bad practice.

Anyway, a properly trained/configured spell-checker could also cope effectively with abbreviated words if care is taken to stick to commonly used abbreviations and not to invent a new abbreviation for every term longer than 10 chars (or worse, different abbreviations for the same term in different part of the code)!

So, to link to what Dirk Laurie said in another message, if you mistake x1 for xi, the programmer who chose those names is at fault. Of course I know that in math world many algorithms contain names that mimick math notations (short and not resembling words of any spoken language), but these cases are relatively rare in the SW world in general.

And anyway, you sometimes can do better in math code spanning longer scopes. For example: "root_i" is often better than "xi" (yes, I know the mathematically inclined could barf at it :-)

My 2 EUR-cent

[snip]



-- Egor