In all the implementation schemes considered before, compilation goes through an independent intermediate code (WAM or similar), which is eventually translated into machine code. Nevertheless, this approach has some major drawbacks:
It would be appealing to have a big part of this work done by somebody else.
Compiling to C (instead using a specialized intermediate language) and using a standard
C compiler as back-end, represents a solution to these problems. The reason for
choosing C instead of other programming languages is mainly related to its
wide availability on any platform, its high efficiency and level of sophistication
of the compilers, and its ability to take advantage of low-level machine
features.
Nevertheless, a straightforward compilation of Prolog to C (e.g., converting Prolog procedures to C procedures, etc.) would produce inefficient executions, due to the deep difference between the nature of the control structures available in the two languages (e.g., iteration in Prolog can be expressed only using recursion). The design of a compiler to C requires developing very smart solutions. Various issues need to be tackled when dealing with Prolog-to-C compilation. The most important is the selection of a proper mapping between Prolog procedures and C functions [30].
Various logic programming languages are currently compiled to C; this approach has been proven to be extremely effective to implement committed-choice languages--which is quite intuitive since supporting backtracking in a Prolog-to-C translation requires a considerable amount of effort--like Janus [24], KL1 [103], and Erlang [51].