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

Robert Jaros

10/18/2023, 7:48 PM
Introducing a new project, I'm working on for a few weeks. Kilua is an experimental web framework for Kotlin/Wasm and Kotlin/JS. It's a very early stage, but I'm sharing the code. Any feedback is welcomed! Please check: https://github.com/rjaros/kilua
👍 12
🚀 2
1
p

Pablichjenkov

10/18/2023, 8:00 PM
What's different from kvision? - the wasm support
r

Robert Jaros

10/18/2023, 8:52 PM
The main difference is the compose runtime usage
State management and reactivity is now the core of the framework. There is also no virtual DOM because compose takes care of DOM manipulation.
KVision api is fully imperative - you can build the layout by creating components and adding them to containers (other components). The reactivity in KVision is a bit strange, because it's based on this imperative api. In Kilua you still have components but you can't build layout with them. Only composable functions are used to create layout.
p

Pablichjenkov

10/18/2023, 8:59 PM
Gotcha, sounds like full rewrite 💪
r

Robert Jaros

10/18/2023, 9:00 PM
Yes, it's a totally different framework (so no KVision2 or even KVision-NG but Kilua 🙂)
😸 1
But still I plan to make it very KVision friendly 🙂 Many parts of KVision application code will be fully working Kilua application code.
p

Pablichjenkov

10/18/2023, 9:03 PM
Sounds good
j

james

10/19/2023, 1:04 AM
hey Robert this is really cool, nice work! I always liked KVision but didn’t do too much with it because I was being lazy and didn’t want to context-switch back into the imperative mode of thinking 😄 I will definitely be closely following Kilua, starred!
s

sdeleuze

10/24/2023, 8:25 AM
Looks interesting, do you have data points for the minimal amount of data to download for a hello world?
r

Robert Jaros

10/24/2023, 9:12 AM
Currently 14K
main.bundle.js
(4K gzipped) + about 1.5M
wasm
file (342K gzipped).
s

sdeleuze

10/24/2023, 9:17 AM
Is the 1.5M coming from Compose infra ?
I am asking because I had related discussion with Compose team about that.
r

Robert Jaros

10/24/2023, 9:18 AM
I think so, compose + coroutines.
s

sdeleuze

10/24/2023, 9:18 AM
Yeah, so that's the usual issue I would like to see solved one way of another.
r

Robert Jaros

10/24/2023, 9:20 AM
Still not bad comparing to compose-web jetsnack example (9MB wasm file + 8MB skiko.wasm + 500KB skiko.js) 🙂
s

sdeleuze

10/24/2023, 9:20 AM
Sure!
I think the path you follow if the right one, we just need to optimize that minimal infra cost at some point
r

Robert Jaros

10/24/2023, 9:21 AM
The same hello world compiled to JS target gives 427K bundle.
👍 1
s

sdeleuze

10/24/2023, 9:21 AM
And that require some design work
r

Robert Jaros

10/24/2023, 9:24 AM
That size will grow a bit soon because
kotlinx.serialization
is coming to play 😉
Just learned about
applyBinaryen
option, which makes my hello-world example wasm file ~890KB (and just ~250KB gzipped).
s

sdeleuze

11/07/2023, 6:23 AM
Yes, this is a must have. Maybe it should be enabled by default 🤔
r

Robert Jaros

11/07/2023, 5:16 PM
With more aggressive optimizations (https://kotlinlang.slack.com/archives/CDFP59223/p1699375103842319?thread_ts=1699023406.875839&cid=CDFP59223) the hello world size is now 460KB (134KB gzipped)!
3 Views