Ann: Paper about Web Prolog (Discussion)

I would expect that would be some time until dedicated Web Prolog native implementations surface. More likely, the first implementations would be Prolog systems providing as a library (or libraries) whatever is required to comply with Web Prolog requirements. As such, and to incentive early adoption and experimentation, I would focus on what’s required to run Web Prolog applications rather than on what’s not required but most likely exists as part of most Prolog implementations. Standardization may become important in the future. But it will be easy to get tangled in the present on discussions about e.g. which subset of Core Prolog to adapt. My suggestion would be to start with a RFC-like process for the fundamental parts (e.g. URI representation and handling) and work towards some consensus.

2 Likes

Can you say some further words on scalability achieved, and security and privacy on the web and in enterprise settings.

Ideally, i think, this should entice developing enterprise apps as well – just like, say, J2EE – a requirement i was asked about some time ago …

Also, web prolog on the server and on the client will have different needs, perhaps you want to show this in the diagram as well …

Daniel

1 Like

Yes, I agree. There probably has to be a Web Prolog profile dedicated to the browser.

Yes, these are good suggestions. Building at least one working implementation of a Web Prolog node is important (and for a W3C standard at least two are required).

However, as I see it, creating a W3C community group, and to do it fairly early, might be a good idea too, as a way to elicit input and find people outside the Prolog community (e.g. AI-related groups, or Semantic Web people) who might be keen on the idea. Creating such a group is really easy - shouldn’t take more than an hour or two.

Creating a report that can be passed on to the W3C would take longer, but if we (in 2022, say) have a comprehensive such report ready, plus two proof-of-concept implementations that are capable of talking to each other, then I think the W3C might allow us to take the next step - to create a proper working group.

2 Likes

You built library(pengines) and said it was an informative experience: that you’d do some things differently if you did it again. It seems as though it’s time to take another run at it to get those proof-of-concept implementations running.

It’d be nice if it was using SWI-Prolog again, it might make iterations quicker as Paulo said above. The more frequently something working is put in front of developers, the more ideas can be tested and refined. Time for a bit of Rapid Application Development? Judging by the length of this thread and the fervent debate in it, there’s support in the community. Let’s hack at it!

Regarding that debate, dicts and strings may be controversial in Prolog, but if you want to bring Python/Ruby/JavaScript etc. programmers on board, these are concepts they understand that will enable them to get up and running more quickly. In fact, it’d be wise to expand upon the built-in string predicates to provide conversions of case, splicing, search, replace, etc. Also, given that programmers will likely wish to integrate their web applications with existing API’s that return JSON, the SWI-Prolog dict abstraction provides these non-expert Prolog programmers with a familiar interface that appears to resemble the JSON data structure. Furthermore, they can choose pairs if they wish.

Regarding accessing browser features like localStorage, in Tau it could be like so with library(js):

localStorage(Key, Value) :-
    var(Value), atom(Key),
    prop('localStorage', LocalStorage),
    prop(LocalStorage, 'get', Get),
    apply(Get, [Key], Value).
localStorage(Key, Value) :-
    atom(Value), atom(Key),
    prop('localStorage', LocalStorage),
    prop(LocalStorage, 'set', Set),
    apply(Set, [Key, Value], _).

How browser features are accessed will depend on whether a browser profile is built with JavaScript or WASM, either way it is not necessary to worry about this yet as they will be accessible and packs/libraries can always be authored.

1 Like

I may be completely wrong here, but I have a feeling that semantic web people, who are deeply invested in description logic approaches – its a huge area of research and industry standard and practice, will have a harder time with a Prolog implementation that doesn’t have a strong formal semantics (and, its an undecidedable language).

There is the stream of datalog research with formal semantics – but, prolog is not datalog.

Dan

1 Like

I came to Prolog from Semantic Web out of frustration at the limitations. I’m not alone in that frustration.

3 Likes

Here’s a blurb from my Erlang’19 paper that says things about scalability:

By adopting a computational model capable of scaling out not only to multiple cores on one machine but also to multiple nodes running on multiple machines, by introducing an option allowing clients to limit the number of network roundtrips it takes to run a query to completion, by embracing the WebSocket transport protocol with its low overhead per message, by offering also a stateless HTTP API, and by leaving ample room for old as well as new forms of caching on both clients, nodes and intermediaries, we have made our best to ensure our high hopes for the scalability of the Prolog Web are not unfounded.

For the Prolog Web to be able to scale really well, nodes must also be able to spawn very many actors, creating and destroying actors must be fast, and the communication among them efficient. Since actors created by the Erlang virtual machine are famous for having exactly those properties, this is certainly yet another reason for us to look closely at Erlang.

Feel free to ask me about what I mean by any of that, and hopefully I’ll be able to answer (although an answer might be in the form of a pointer to a section of my manuscript or the Erlang’19 paper).

1 Like

Although I haven’t really worked much with the SW technology, I have the same impression. Starting from distributed Prolog might be a much better idea.

Yes, to continue working on the SWI-Prolog implementation would likely be the best way forward. What’s missing more than anything else is the ability to run the PoC online, and for that the sandboxing must be dealt with. I’ve made several attempts at that, but failed each time. :frowning:

The tutorial included in the PoC also points to a couple of bugs, but nothing as severe as the lack of security.

Note that there are sound technical reasons why dicts and strings are controversial. In particular, strings as implemented in SWI-Prolog have been extensively debated when SWI-Prolog 7 was introduced. Dicts use a functional notation with eager evaluation and an operator that the ISO standard and almost all Prolog systems use for representing lists. I’m not trying to (re)open the debate on these features here (specially in this thread) but Web Prolog work that assumes strings and dicts as materialized in SWI-Prolog risk excluding other Prolog systems from participating at the start gate. Moreover, anyone thinking that this is just other systems being slow in keeping pace, well, that’s naive and ultimately wrong. Both strings and structures in named arguments (aka as dicts) were found in other Prolog systems long before SWI-Prolog 7. So far, no consensus on these features syntax and semantics have emerged from the broad Prolog community, much less any standardization efforts around it. Not trying to rain down on the Web Prolog initiative. Just alerting that there’s work to be done here.

3 Likes

Couldn’t containers provide a solution to the security problem? Spin up duplicate nodes in containers, which can give us load balancing, redundancy and the ability to send a long-running query to another node to try. Definitely scalable! We can kill and spin-up containers at will, ala. Kubernetes Why not use ideas from the big data/serverless communities here? It leaves the realm of programming language and enters that of a framework, but it’s one option.

1 Like

The only way to get this kind of project truly moving is to follow what Linus said once about open source (paraphrasing): for an open source project to work someone has to be willing to take charge of the code and work on it (without expecting the ‘community’ to do the work); no open source project will succeed unless there is a ‘coder’ that takes ownership and releases early and often.

We have seen this with Linux, SWI-Prolog, gcc, vim, emacs, python, perl, elixir, ruby, netscape (early days of web, before it was a company), keepass, etc. It is only after this ownership and continuous development is in place that a community will truly develop around it.

I think Web Prolog is really needed and a very good idea, but it will never get off the ground until one person takes the code and develops it with a long term commitment, releasing early and often.

Keeping the discussion at the theoretical level is nice, but in the end Web Prolog will never exist. The PoC is a very good start, but it has been frozen in terms of code for long periods of time. This gives the general perception (wether true or not) that the project is simply nice talk, and will not get off the ground until the code base is continuously developed and released often.

I don’t see ‘code ownership’ happening right now for Web Prolog (look at the commit log in github). I do hope some individual appears and takes charge of it.

If that happens, Web Prolog will take off.

2 Likes

Yes, that’s probably what has to happen. I’m afraid that one person can’t be me, though. For one thing, I’ve realised that my programming skills are probably not sufficient. I suspect it might require someone like Jan or Paulo or Richard O’Keefe taking charge (although there might be others, of course, I just don’t know… please step forward if you feel like taking on the challenge!).

(BTW, I sent a copy of a draft of my Erlang’19 paper to Richard O’Keefe, and one of his comments (he had many) was:

I should tell you that I am liking what I see very much and would enjoy using this.

As some of you know, Richard isn’t exactly easy to please, so I felt very encouraged. :slight_smile: )

Alas, I’m getting old (I’m 60), and the kind of focus required for a serious programming effort tends to wear me out. I’ve suffered several burn-outs during the last ten years, and I’m down to working just 50%, probably for the rest of my career.

Now, on the positive side, my department here in Gothenburg has been very understanding, and I’m allowed to spend most of this time on my own research. So, I plan (and I pledge) to spend at least 15-20 hours a week on the Web Prolog project, if we can get something going. Apart from implementation work, there’s more specification work to tackle as well. The current proposal is just a start, and I’d probably need help with the rest as well. I need to publish papers, of course, and I would also like to finish my book (I’d love to find suitable co-authors for both papers and book).

3 Likes

Very true. But then, this is the case for many things that are generally considered vital such as a module system, threads, C interface, attributed variables, global variables, mutable terms, fix ancient arithmetic and a few more. The only difference is SWI-7 came with syntactical changes to accommodate them better. I think we now know the practical implications of these changes are not that large. If we had a working standardization process that should all have been resolved long ago. You gave it a good try (thanks), but right now the process is stuck and given the distribution of power and interest as well as the ISO procedure this is unlikely to change.

I have decided to stop wasting my time on that and move on. That is not necessarily forever. If an initiative comes up that is prepared to make changes, committed to resolve (most of) the above issues and is backed up with people willing to invest time, I’m on board.

That said, it might be wise for Web Prolog, if it aims to be cross-implementation, to avoid syntax that is fundamentally non-ISO. Of course, the alternative view is that you design Web Prolog to be as good as it can be and hope Prolog systems will accommodate the features it needs.

3 Likes

In theory I could drive such an effort. In practice I would need funding to do it, since currently i am working on an own venture without outside funding.

How are such efforts typically funded – does it require a full time commitment?

Dan

1 Like

I think it would be wise to advertise Web Prolog and its call for participation on more venues. Notably, most Prolog compilers have their own mailing lists. That said, SWI-Prolog is particularly well suited for a Web Prolog implementation given its focus on web technologies. No surprise to see it taking point.

There may (or already there is; sorry if I missed it) a third view of Web Prolog as a set of minimal APIs that allow networked nodes running Prolog (or other logic programming systems) to cooperate, In this view, each system strengths (including proprietary extensions) could be used at full capacity and standardization issues would be minimized as the efforts would focus in the communication between nodes. If all nodes would be capable of advertising and being queried about the Web Prolog profiles they implement, any node would know how to talk to any other node. But maybe all these is already being planned? I have not been able to fully follow the discussion.

1 Like

One thing that wouldn’t work if only minimal APIs are standardised is what I refer to as code injection, i.e. the ability to inject Web Prolog source code into a pengine (or other kind of actor) to be created. Code injection is involved already in the interaction between SWISH and the backend when a pengine (of the “old” kind) is being created. In my opinion, the injected code has to adhere to a standard, which might be big or small, depending on the profile.

Preserving each system’s strength’s is important, but I believe this is easier if more comprehensive profiles are specified. Also, I propose only less than a dozen of Erlang-ish predicates for taking care of spawning and messaging. I don’t see that they should be very difficult to standardise.

Advertising Web Prolog more broadly is a good idea. Perhaps this can be done by writing something that can be published on the ALP site? Perhaps ALP - as an organisation - would like to see Web Prolog happen? As a way to celebrate the 50th anniversary of the first LP language that has had some success?

Could you give an example for the requirement and use of code injection – i am not familiar with this need – the word injection causes me to think about viruses and other nasty stuff off and on the web :slight_smile:

Dan

Ok, if you’ve read the paper, you may have noticed the many places where options such as src_text, src_predicates, src_list and src_uri are passed when spawning a pengine or another actor. Such options allow you to inject source code into the private workspace of a local or remote actor and to have them run it. In the web APIs, there are query parameters which serve the same purpose.

Yeah, “code injection” may be a bad choice of term…