Hi, does anyone here know if something like Perceu...
# webassembly
p
Hi, does anyone here know if something like Perceus (reference counting) would work in Kotlin for Wasm? https://www.microsoft.com/en-us/research/uploads/prod/2020/11/perceus-tr-v1.pdf
s
Current Kotlin/Native based Wasm target prototype has form of reference counting, but it is moving away from it: https://blog.jetbrains.com/kotlin/2020/07/kotlin-native-memory-management-roadmap/ I’m not familiar with Perceus, but skimming the paper, they seems to have an open issue with cycle collection, which would need to be solved to be used in language like Kotlin, where you can freely form reference cycles without weak references. In Kotlin/Wasm we want to use GC of JS engines (instead of custom GC like Perceus) to simplify collecting cycles between Wasm, JS and DOM tree.
p
Thanks for the explanation
An interesting use case for wasm is in serverless computing at the network edge. It would be great to be able to use kotlin and not have to use other languages. One of the leading proponents is fastly and they don’t have a js engine, though cloudflare supports JS and therefore probably kotlin. https://www.fastly.com/blog/evaluating-new-languages-for-edge-compute
s
I think it will be possible to compile Kotlin to Wasm in a way for it to be able to run in a standalone Wasm runtime. Although it is not our top priority at the moment. First we want browser use-case to be covered well. Hopefully edge computers would support Wasm GC when it matures. Even if they would not do that natively, I believe that generic “Wasm w/ GC” -> “Wasm w/o GC” converter can be done (assuming you don’t interact with host GC).
1