webassembly

Discussions related to Visual Prolog
drspro2
VIP Member
Posts: 75
Joined: 28 Apr 2006 12:03

webassembly

Unread post by drspro2 » 27 Jul 2020 6:21

they say it is already possible to convert C-code to webassembly code,

would it theoretically be possible to let VP generate webassembly code?

the other way would be to make a prolog parser to parse prolog code, and then write a prolog program which can output webassembly code for this parsed prolog code

User avatar
Thomas Linder Puls
VIP Member
Posts: 1168
Joined: 28 Feb 2000 0:01

Re: webassembly

Unread post by Thomas Linder Puls » 27 Jul 2020 20:19

(Your "other way" seems to describe a compiler, which is also what the first part is concerned with).

It is long time since I looked at WebAssembly and things may have changed since then. My conclusions at that time was the following.

There would be some complications for Prolog
  • The instructions/"processor" did not support backtracking in the form we normally use.
  • Tail calls was not supported or limited.
These complication can most likely be handled, but more important from my point of view:

WebAssembly does not seem to be a first class citizen in the browser(s) like JavaScript. Basically WebAssembly will be a "standalone program in a rectangle" in the HTML page, which will require a lot JavaScript to integrate with the surrounding HTML.
Regards Thomas Linder Puls
PDC

drspro2
VIP Member
Posts: 75
Joined: 28 Apr 2006 12:03

Re: webassembly

Unread post by drspro2 » 27 Jul 2020 20:49

thankyou for the information,

the last sentence about webassembly sounds a bit odd to me, as my understanding was that WebAssembly is now adopted and supported by all current webbrowser engines, also they have plans to keep developping it alongside normal javascript.

User avatar
Thomas Linder Puls
VIP Member
Posts: 1168
Joined: 28 Feb 2000 0:01

Re: webassembly

Unread post by Thomas Linder Puls » 28 Jul 2020 21:20

Yes, I agree on that aspect; it is the role it has in the browsers that I am concerned with. JavaScript, HTML and css, are all collaborating on the "web page", but WebAssembly seems more like an embedded application like the less and less frequent flash applications.
Regards Thomas Linder Puls
PDC

drspro2
VIP Member
Posts: 75
Joined: 28 Apr 2006 12:03

Re: webassembly

Unread post by drspro2 » 29 Jul 2020 5:41

yes that is right, webassembly runs separatly like a flash applet or java applet, though they have already tackled this point, the way of communicating for the webassembly module to the data in the javascript is already completely described in the design.

for example there exists already an IDE with language Rust ( made by mozilla ) which generates code for the web assembly module to connect with the javascript,

also there exists the language webassembly script which can compile to webassembly code.

as far as i can understand it, it seems to be as such that,

Type-script is al logical follow up for javascript , it is javascript with type safety ( maybe the same
as the relation which visual prolog has to normal prolog, it helps the prorammer for type checking )

then webassembly-script looks much like Type-script, so it becomes a very easy next step

with prolog one could write a parser which can parse prolog and generate webassembly code,

but VP is much faster because it has a C-program which does the parsing and compiling , or is VP using its own prolog code already
as a tool instead of C code?

User avatar
Thomas Linder Puls
VIP Member
Posts: 1168
Joined: 28 Feb 2000 0:01

Re: webassembly

Unread post by Thomas Linder Puls » 29 Jul 2020 15:52

The parser for Visual Prolog is in the Commercial Edition in the directory vip/vipSyntax. It is almost completely in Prolog, only a little of the lexer is in C/C++. It is generated by the LALR parser generator.

As for the other matter it still seems to me that HTML, css and Javascript is used to create active web pages. Whereas WebAssembly is something that can run in a web page as a rather independent thing. The WebAssembly code can interact with the JavaScript code, but it cannot directly interact with web page. So WabAssembly does not seem to be useful for creating active web pages, it rather seems like a way deploy non-web applications. That can also be interesting, but you will either need to write the entire application from scratch (dealing with mouse clicks, keyboard and everything) or find some library software and figure out how to interact with that from your code.
Regards Thomas Linder Puls
PDC

drspro2
VIP Member
Posts: 75
Joined: 28 Apr 2006 12:03

Re: webassembly

Unread post by drspro2 » 30 Jul 2020 8:00

I thought that I had found a javascript webassembly example where the webassembly interacts with the canvas in the HTML page, this is the FANN library in javascript implementation.

so when VP itself uses prolog as a developping language that should proof that it is fast.

despite the fact that Artificial intelligence seems now te be used and accepted everywhere in society, to me it seems that prolog is still not accepted for programmers in companies. To me it seems that the companies are looking for python or C programmers to implement their AI.

maybe prolog is better for building knowledge based systems which is still not happening yet? and that there may eventually come a time when prolog is asked for everywhere?

Post Reply