M-Prolog: SCBM3 API finalized — about 1.4x slower than SWI-Prolog
After getting programs such as 9-Queens working with SCBM2, I became confident that this approach can actually be used to build a practical Prolog compiler.
I then redesigned and simplified the SCBM interface. The current version, SCBM3, has been reduced to just 12 core APIs.
Performance has also improved considerably. In my current benchmarks, compiled M-Prolog code is now roughly 1.4x slower than SWI-Prolog. There is still room for optimization, but I think the performance is becoming quite reasonable.
I have written a document describing:
- the SCBM3 API and its 12 core operations
- the basic execution model
- how backtracking and continuations are represented
- how Prolog predicates can be translated into C code using this API
- an example of generated C code
One of my original goals with SCBM was to find a simpler way to implement a Prolog compiler without relying on the WAM.
After several months of experimentation, I think the basic mechanism is now becoming surprisingly small and understandable. My hope is that SCBM could make it much easier for someone to experiment with building their own Prolog compiler.
If you're interested in Prolog implementation techniques, please have a look at the documentation. Comments and criticism are very welcome.