« Return to Thread: Returning JSON output from a handler thread still running?

Web-Prolog server demo

by Jan Wielemaker-3 :: Rate this Message:

Reply to Author | View in Thread

Hi all,

Torbjörn sent a little program to communicate with Prolog using a
browser.  This problem has some interesting aspects that have been
discussed here several times:

    * Deal with state in Prolog web-servers, where the state is
    maintained on the Prolog stacks (stack, choicepoints, variables).

    * Deal with interactive web-applications (AJAX)

    * Deal with safely calling Prolog code

    * Deal with handling multiple `theories'

Turning this into a nicely working demo can serve several purposes

    * Provide online demos to attract people to your nice library/etc.
    Think of CHR, CLP(FD), etc.  Ulrich: online GUPU?

    * Provide a nice skeleton that can help making Prolog
    more inspiring for students.  It shows cooperation with modern
    web technology and allows them to write something that is nice
    to show to friends.

    * Provide a design pattern and libraries to deal with the four
    issues mentioned above.

Please find below some of the discussion.  I've put the current code
in a new GIT repository on www.swi-prolog.org.  See

        http://www.swi-prolog.org/git/web-prolog.git
or git clone git://www.swi-prolog.org/home/pl/git/web-prolog.git

Who is interested in helping?

        Cheers --- Jan

On Thursday 25 June 2009 05:47:05 pm Torbjörn Lager wrote:

> Jan,
>
> That looks great! I also got myself a valuable lesson, not only for
> how deal with threads in SWI, but also how to debug, etc.  Please go
> ahead and make that announcement on the list. I suppose an N-queens
> demo or something would work, and if no one else steps forward, I'm
> sure I could build one myself.
>
> I was also thinking about creating a small javascript library to accompany
> the code - something that encapsulates the first-next-stop protocol.
> But in order to avoid a dependency on any particular Javscript
> library, maybe it's better to have the server return errors if things
> show up in the wrong order? (I commented out the button selection code
> and I as was the able to break the server...).
>
> What would be the proper way to handle (secure, perhaps also with
> restrictions on size) uploads? To load them into a module created with
> the name of the session?
>
> Shouldn't we rather put safe/1 in a module of its own? Seems somewhat
> orthogoal to the rest of the prolog_server module...
>
> I think spending time on this library is well worth the effort - so
> many interesting apps one could build on top of it!!
>
> BTW, did you check out my chat-demo? Simple, but still something that
> people might want to do.
>
> Thanks!
>
> Best,
> Torbjörn
>
> 2009/6/25 Jan Wielemaker <J.Wielemaker@...>:
> > Torbjörn,
> >
> > I used your file as a source of inspiration. See the modified version
> > attached. There where some issues in your thread handling. Notably,
> > there is little reason to spawn the server threads, but there is reason
> > to manage the solving threads. Also, /prolog/next *can* arrive on a
> > different thread!
> >
> > Would be nice to modularise this a bit further and add support for
> > upoading a program. If we can get all this working we might be able to
> > create a nice tool for the community and a nice demo for handling state
> > through Prolog web-servers.  One of the issues in safe compilation.
> >
> > Now, I just send the files to you privately. Shall we (you? I?) make a
> > query on the list to see if there are people willing to turn this into
> > a nice example and Prolog-demo?
> >
> >        Cheers --- Jan

_______________________________________________
SWI-Prolog mailing list
SWI-Prolog@...
https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog

 « Return to Thread: Returning JSON output from a handler thread still running?