DEV Community

Discussion on: The JS developer's view of WASM in 2019

Collapse
 
jtenner profile image
jtenner • Edited

Asking and requiring AssemblyScript to support reference types before they are supported in the Web Assembly Specification is asking a lot for an MVP.

For instance, you personally can fix your problems by using the AssemblyScript loader provided in the "assemblyscript/lib/loader" module.

import { instantiateStreaming } from "assemblyscript/lib/loader";

const module = await instantiateStreaming(fetch("my-module.wasm"), imports);
const importantString = module.getString(module.return_string());

These criticisms levied against AssemblyScript are not valid, because AssemblyScript is also young, and is worked on by a very dedicated group of developers. Strings are stored as utf-16 and encoding and decoding strings was one of the very first features they supported.

As for speed, there are examples of emulators like wasmboy which is a very good proof of concept that AssemblyScript can be used in high performance situations.

I have personally worked on an RPC library called as2d, located here, which emulates the CanvasRenderingContext2D stack machine and performs a virtual diffing algorithm that reduces JavaScript function calls to the canvas prototype by 40% for common use cases and memory consumption by nearly 50% when drawing to canvas.

I doubt writing an article and claiming something "sucks" in this way will be helpful. We all value speed, efficiency, and code that delivers great user experience. I don't think there's a need to act this way, because the purpose of criticism is to make things better. Not worse.

There are plenty of things wrong with AssemblyScript, and you have stated none of them here.

Hope this helps,
-Josh

Collapse
 
neutrino2211 profile image
Mainasara Al-amin Tsowa

Thanks, this really helped. I now understand that looking at assemblyscript as a disadvantage is not fair and the opposite should have been the case, i personally use assemblyscript and instead of outlining its shortcomings I should have acknowledged the fact that whatever the case it does a good job at what it promises. Once again thanks for the feedback, it really helped to hear from someone who better understands the inner workings of such projects and I will rewrite this post to be a fair representation of the situation

Collapse
 
jtenner profile image
jtenner

Please do a great job. I know you will.

Thank you for the kind response.
-Josh