Update: Runtime Choice
As promised, I tried to experiment with various runtimes for our new engine. The archive contains:
- A source code for implementation of a pathfinding algorithm in C, Lua and Pawn
- A compiled amx executable from Pawn code (32-bit cell size)
- A compiled Windows executable from C code (Mingw-64-10.0.0 with GCC 12, custom CRT and executable built for i486 cpu)
- A compiled amx, lua 5.4 and lua 5.5 runtimes (Mingw-64-10.0.0 with GCC 12, custom CRT and executables built for i486 cpu)
WASM
Existing runtimes are too complex and either are written in not portable languages, or require modifications for portability (too strictly tied to OS versions). From actively supported and seemingly matching my requirements I found only two implementations:
- WASM3 does not work on Windows XP or lower due to using some new api functions
- I was unable to compile WAMR for Windows from GNU/Linux, so was unable to test
Compiling with existing tools is not possible on most platforms -- you'll have to run a fairly recent version of Windows or GNU/Linux to do this, limiting game development options severely.
Spending more time on resolving these issues is not feasible since there are too many unknowns + overall complexity of the platform may be an issue with porting.
Pawn
- Compiling and making work required some effort(certain things are platform-dependent by default, but can be changed by compiler options; We are optimising for 32-bit systems, so we are using 32 bit cell size), however the runtime is lean and runs without any issues on Windows 95 out of the box (there is even 16 bit Windows support)
- Has native support for fixed-point arithmetics. This is not highly critical, as it can be implemented in Lua pretty easily
- Overall the language is pretty minimalistic
- String handling is done C way which is... problematic for writing games in the language. There are literally no built-in ways of complex string processing
- Only fixed (at compile time) size arrays -- this is critical to using Pawn in our project. This seemingly can be implemented in amx assembly
- No OOP -- developing a full-fledged game like that would be a pain.
Performance
I got these results on 86Box (5.3, build 8253 old dynarec; Windows 95 OEM, Pentium 133, ASUS P/I-P55TP4XE more details (PNG)). All times in seconds:
C: 23.5
Pawn: 694.3
Lua 5.4: 405.1
Lua 5.5: 401.9
And these on real hardware (Windows 98 SE; Pentium MMX 233, EPoX EP-MVP3G2, 256 MB RAM). All times in seconds:
C: 36.0
Pawn: 482.5
Lua 5.4: 270.8
Lua 5.5: 258.4
C is only present here for reference as "we can't be faster than this" (except by optimising). And Lua is a clear winner, so it stays as our choice. During the development of the engine we'll continue to check newer Lua versions and update to them if they yield any benefit.
I will update the original article with this information.
Thank you for reading, as always I'm waiting for your feedback on email. Until we meet again!