Upgrading JavaScript engine options
Posted: Mon Dec 01, 2025 7:18 am
I want to discuss Javascript engine options.
With some work, I built the Spidermonkey from Firefox 23 (just before the major IonMonkey change). I had hoped it would still be fairly similar to the Spidermonkey used by Oolite, but when trying to build Oolite to use it, I ran into a problem. Spidermonkey 23 headers include C++ and an Objective-C .m file including a C++ header is not possible. This could be solved by renaming .m to .mm which allows C++ and making whatever changes are needed to support calling C++. Since this requires changing Oolite code, it would make more sense to invest the time on a much more modern Spidermonkey - for example Ubuntu has packages for Spidermonkey 115.
However, I thought I would look for alternatives and came across some pure C JavaScript engines, the most promising of which is QuickJS-ng which supports several platforms including MinGW64. This one is actively maintained, supports modern JavaScript and is actually designed to be embedded in other projects unlike Spidermonkey which is specifically tailored to Firefox. Its API has some similarities to the Spidermonkey currently used by Oolite.
The last option is to try to clean up the Spidermonkey that Oolite uses so that it is far less opaque than it is now effectively locking Oolite permanently to that version. The problem is right now, the only platform for which it builds cleanly is Linux. Windows requires a custom version of the code whose changes are not documented or understood. It has not been built on modern Mac and it may not be possible. Modernisations needed include removing the hard dependency on Python 2 which is obsolete by upgrading all Python 2 code to Python 3.
What are your thoughts?
With some work, I built the Spidermonkey from Firefox 23 (just before the major IonMonkey change). I had hoped it would still be fairly similar to the Spidermonkey used by Oolite, but when trying to build Oolite to use it, I ran into a problem. Spidermonkey 23 headers include C++ and an Objective-C .m file including a C++ header is not possible. This could be solved by renaming .m to .mm which allows C++ and making whatever changes are needed to support calling C++. Since this requires changing Oolite code, it would make more sense to invest the time on a much more modern Spidermonkey - for example Ubuntu has packages for Spidermonkey 115.
However, I thought I would look for alternatives and came across some pure C JavaScript engines, the most promising of which is QuickJS-ng which supports several platforms including MinGW64. This one is actively maintained, supports modern JavaScript and is actually designed to be embedded in other projects unlike Spidermonkey which is specifically tailored to Firefox. Its API has some similarities to the Spidermonkey currently used by Oolite.
The last option is to try to clean up the Spidermonkey that Oolite uses so that it is far less opaque than it is now effectively locking Oolite permanently to that version. The problem is right now, the only platform for which it builds cleanly is Linux. Windows requires a custom version of the code whose changes are not documented or understood. It has not been built on modern Mac and it may not be possible. Modernisations needed include removing the hard dependency on Python 2 which is obsolete by upgrading all Python 2 code to Python 3.
What are your thoughts?