Assemblyscript plugin example

54 views
Skip to first unread message

Simon Frost

unread,
Mar 23, 2019, 4:52:25 PM3/23/19
to iodide-dev
Dear All,

I updated the Assemblyscript codepen example (https://codepen.io/ds604/pen/432d293df115432859f0af62e69d2e64) to work with the current syntax:


However, updating binaryen and Assemblyscript to the latest version throws a window[n] undefined error:


Any ideas about what is going wrong?

Best
Simon

Brendan Colloran

unread,
Mar 23, 2019, 7:53:19 PM3/23/19
to Simon Frost, iodide-dev
(Not actually related to your problem, but I did notice a typo -- ""asmScriot" instead of "asmScript".)

I don't really know what might be going on, but i do notice a couple things looking around in the devtools console:

* fetch chunks load scripts in parallel, and it looks like the second script you fetch might need something from the first -- if you put both scripts in one chunk you get an error "TypeError: r is undefined"

* If you load those scripts sequentially by splitting up the fetches:
```
then you don't get the type error, but then below when you load the plugin chunk you get `TypeError: can't redefine non-configurable property "signbit"` (and the plugin loader hangs, which is a bug :-( ... )

* if you comment out the second line of the fetch and let the plugin loader retrieve that file, you don't get any errors in devtools, but you get:
```
TypeError: assemblyscript.CompilerTarget is undefined
asmScript.eval()@cell:8:6
```
in the iodide console when trying to run the assemblyscript cell.


Maybe there is a clue in one of those things? @mdboom may be able to say more about how to write a plugin loader helper script that can streamline loading binaryen etc in the correct order, and generally has the most knowledge about wasm etc of anyone on our team. Hopefully he can help.

I think this is really exciting btw! Some of the performance wins potentially available from assemblyscript could make it very interesting for numerical computation and visualization. Please do continue to reach out, we'd love to help! And feel free to ping us on gitter if you want real time chat: https://gitter.im/iodide-project/iodide

-brendan

--
You received this message because you are subscribed to the Google Groups "iodide-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iodide-dev+...@googlegroups.com.
To post to this group, send email to iodid...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/iodide-dev/994dcc27-28f0-406b-ae1b-876f59c5866b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Sarma

unread,
Mar 24, 2019, 2:43:56 AM3/24/19
to iodide-dev
There were some changes to the Assemblyscript interface for compiling the function. Here's a stripped down example with their new way of doing things: https://codepen.io/ds604/pen/cd0ac597fa2d4ab05f0d531a1c9828cb. (And I just put it in an Iodide notebook too: https://alpha.iodide.io/notebooks/1250/)

I didn't realize those language plugins were linked to, I guess the other ones (the Lua and Ruby ones) could use an update too since they don't really work as they are on the Codepen link.

-David

I like the new RStudio style btw! I didn't realize the redesign was going to be such a jump from the notebook format from before. This might belong in a different topic, but regarding numerical computing: I had a few thoughts about the syntax extensions that I remember were mentioned on the home page previously. I was looking through some different linear algebra possibilities like tensorflow.js, Jama, nd.js (and I'm sure there are probably a bunch more). But I thought that having a Matlab-style slice syntax might be nice, so that whichever one happens to find usage, there's just a familiar way of just getting going with it.

Simon Frost

unread,
Mar 26, 2019, 8:04:30 AM3/26/19
to iodide-dev
Dear Brendan and David,

The notebook now works:


For some reason it needs 'ts-node', even though it should be entirely client-side.

I also had to change the Codemirror mode to Javascript as Typescript mode isn't in the Codemirror linked to by Iodide.

Best
Simon

David Sarma

unread,
Mar 29, 2019, 1:30:46 PM3/29/19
to iodide-dev
Simon: Thanks, I couldn't quite get the plugin working before, so, glad you figured that out.

I just updated the links for the Lua and Ruby plugins, but also made a page with just the plugin text, along with some sample usage: https://github.com/ds604/iodide-language-plugins. So in case something like that might help to keep some additional notes on what's required (like which ones require additional helper functions, or in-order execution spanning across multiple cells to set up), or the different manner of usage, like how to share variables from/to javascript, and the different issues that come up.

-David
Reply all
Reply to author
Forward
0 new messages