Re: Pengine - the Prolog engine running SWISH

"Richard A. O'Keefe" <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 16/08/2013, at 7:34 PM, Jan Wielemaker wrote:

> On 08/16/2013 01:50 AM, Richard A. O'Keefe wrote:
>> My second reaction was, "you know, given emscripten and Asm.js,
>> that 'good Prolog engine written in Javascript' could *be* SWI Prolog".
> 
> How do you see that?  The code base is unusable as JS asks for a
> quite different design than C.

Step 1.  Compile the C code to LLVM bitcode using clang.
Step 2.  Compile the LLVM bitcode to JavaScript using emscripten
         (http://en.wikipedia.org/wiki/Emscripten).
Step 3.  Asm.js (asmjs.org) is a sublanguage of JavaScript.  An
         Asm.js-aware JavaScript implementation (such as a recent
         versions of FireFox) can compile it to native code that's
         within hailing distance of C->native direct compilation.

Of course, with JavaScript having no threads, some things wouldn't
port.  I've never used emscripten or asm.js myself, but I'm led to
believe that it would be more like a port to a new (and crippled)
operating system than anything else.

Some of the libraries wouldn't port, and the top level driver might
be different, but I would expect that the compiler and the emulator
would be OK.

> Note that a colleague of mine does a lot of app development and generally
> claims you should not try to compute on the local device as that drains
> the batteries really fast.  Now, I assume there is not a single truth
> here ...

Well, there's computing and then there's computing.  It all depends on
what your local device _is_.

Some people might want Prolog-in-the-browser on a desktop machine, for which
the battery is not an issue.  Some people might be more interested in a
laptop.  Others in a tablet.  (For which the radio and the display might be
a bigger drain.  I know the tablet I use lasts a lot longer when I turn the
radio off.)

When I'm using my laptop, I can read and develop for about 6 hours before it
is time to recharge, and the machine's cool.  When I run the regression suite,
the CPU usage meter pegs at 100% and the machine gets quite hot and the
battery runs down much faster.  So yes, *steady*, *heavy*, computing will
drain your batteries.  But *bursts* of computing needn't.  It would be
interesting to compare Prolog power use with say watching a movie.  I had an
application that could have told me that, but the "upgrade" to Mac OS X 10.7
not only ruined the user interface (I really _need_ arrowheads on scroll bars)
but broke that application.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.