https://kotlinlang.org logo
#webassembly
Title
# webassembly
s

sdeleuze

07/25/2021, 8:02 PM
Any take on this from a Kotlin perspective ? https://twitter.com/assemblyscript/status/1419110937261449216?s=21
n

napperley

07/25/2021, 11:40 PM
The main takeaway from this announcement is that Kotlin WASM needs to develop its own ecosystem, and not rely heavily on JS interop, which may not be guaranteed with the WASM platform.
It may be very likely that JS libraries can't be used on WASM anyway. I hope that Kotlin WASM doesn't have a heavy reliance on JS like AssemblyScript does 🙏, otherwise there would be no point in developing Kotlin WASM further.
With WASM there would need to be some standard way to support strings in some form (obviously NOT in JS form) with its ABI. Many APIs use strings, and no string support would severely hamper WASM's usability as a platform.
If you look at Kotlin Native with the Linux platform for example, Kotlin accesses strings from the C side via
CPointer<ByteVar>?
, and converts the fake C string to a real Kotlin string via the
toKString
function (the main way to do it). Something similar would need to be in place with the WASM platform.
In the worst case scenario Kotlin WASM may need to have interop with the C++, and Rust programming languages in order to access third party WASM APIs.
a

altavir

07/26/2021, 6:10 AM
I agree about independent ecosystem. Kotlin stdlib and kotlinx already rival most of JS ecosystem (save for styling frameworks like bootstrap). In my experience, the most struggle with JS ecosystem is quality of those libraries, and I do not see problems with doin things from scratch on kotlin.
s

sdeleuze

07/26/2021, 7:01 AM
Thanks for sharing your thoughts
s

Svyatoslav Kuzmich [JB]

07/26/2021, 11:18 AM
Notice seems to be lacking some context. What are the “unresolvable correctness and security problems”? Is it about not being able send arbitrary binary data, possibly invalid Unicode, via string type of Interface Types proposal?
s

sdeleuze

07/26/2021, 11:32 AM
I think

https://youtu.be/Ri2NMnSQo4o

is related if you want more context.
If UTF-8 is chosen for Wasm String early august, will Kotlin/Wasm use that natively?
I am not too puzzled by the JS interrop, but I am wondering if that could be an issue for Kotlin or JVM worlds.
s

Svyatoslav Kuzmich [JB]

07/26/2021, 2:30 PM
If UTF-8 is chosen for Wasm String early august, will Kotlin/Wasm use that natively?
We would want to still use WTF-16 for multiplatform consistency. But I doubt that UTF-8 would be chosen as the only encoding for browser API and JS interop, because JS and DOM strings are WTF-16 and many languages with matching encoding would want to pass strings back and forth without double conversion.
s

sdeleuze

07/26/2021, 2:33 PM
Ok so I guess we will have to define the boundaries of what is exposed like
@JsExport
, maybe via something like
@WasmExport
?
I guess the AssemblyScript team is puzzled because they had full compat until now via custom binding generation and the standardization of Wasm string will force them to identify what is exposed and what is not ...
s

Svyatoslav Kuzmich [JB]

07/26/2021, 2:36 PM
I hope that Wasm would expose some low-overhead access to JS strings from inside Wasm. We could use these as Kotlin/Wasm string and avoid copy at the boundary.
s

sdeleuze

07/26/2021, 2:36 PM
Ok I see
Maybe worth to check with Google is that's the plan before the vote August 3rd.
That would be useful for a lot of languages
s

Svyatoslav Kuzmich [JB]

07/26/2021, 2:47 PM
Just for the context, the poll will be about https://github.com/WebAssembly/interface-types/issues/135
s

sdeleuze

07/26/2021, 4:11 PM
Interesting thanks for sharing. Glad Luke Wagner is leading this, I have a deep respect for his work.
n

napperley

07/26/2021, 11:11 PM
There is no guarantee that WASM will allow access to JS/DOM APIs. I agree with Alexander Nozik that Kotlin would be fine on having APIs built from scratch. It is looking increasingly likely that WASM will be a black canvas, and that custom Kotlin APIs will be required to provide the foundations. This could be the first Kotlin development platform in history that heavily relies on Kotlin APIs unlike the other Kotlin development platforms (Kotlin JVM, Kotlin Native etc).
👍 1
s

Svyatoslav Kuzmich [JB]

07/27/2021, 8:38 AM
JS/DOM APIs are already available in Wasm. The main problem is that browser APIs are routed through JS, which is suboptimal given that both sides are statically typed. Interface Types is promised to be a solution to this in the future.
👍 1
👍🏼 1
4 Views