From 635b7b1b9ca91e8b606730445f060800117ff7c5 Mon Sep 17 00:00:00 2001 From: alepedroza <39709865+AlejandraPedroza@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:08:59 +0100 Subject: [PATCH] update: restructured the overview according to skuzmich review and other minor changes. --- docs/topics/wasm/wasm-overview.md | 60 ++++++++++++++++++++--------- docs/topics/{ => wasm}/wasm-wasi.md | 15 +++++--- 2 files changed, 50 insertions(+), 25 deletions(-) rename docs/topics/{ => wasm}/wasm-wasi.md (87%) diff --git a/docs/topics/wasm/wasm-overview.md b/docs/topics/wasm/wasm-overview.md index 050a09ba8f0..1a35523a9aa 100644 --- a/docs/topics/wasm/wasm-overview.md +++ b/docs/topics/wasm/wasm-overview.md @@ -1,19 +1,36 @@ -[//]: # (title: Kotlin Wasm) +[//]: # (title: Kotlin/Wasm) -> Kotlin Wasm is [Alpha](components-stability.md). +> Kotlin/Wasm is [Alpha](components-stability.md). > It may be changed at any time. You can use it in scenarios before production. We would appreciate your feedback in [YouTrack](https://youtrack.jetbrains.com/issue/KT-56492). > > [Join the Kotlin/Wasm community](https://slack-chats.kotlinlang.org/c/webassembly). > {style="note"} +Kotlin/Wasm has the power to compile your Kotlin code into [WebAssembly (Wasm)](https://webassembly.org/) format. +With Kotlin/Wasm, you can create applications that run on +different environments and devices, which support Wasm and meet Kotlin's requirements. + +Wasm is a binary instruction format for a stack-based virtual machine. This +format is platform-independent because it runs on its own virtual machine. Wasm provides Kotlin and other languages with +a compilation target. + +You can use Kotlin/Wasm on different sub-platforms, +including [Compose Multiplatform](https://www.jetbrains.com/lp/compose-multiplatform/) for web applications +and [WebAssembly System Interface (WASI)](https://wasi.dev/) for server-side applications. + +## Kotlin/Wasm and Compose Multiplatform + With Kotlin, you have the power to build applications and reuse mobile and desktop user interfaces (UIs) in your web projects through Compose Multiplatform and Kotlin/Wasm. [Compose Multiplatform](https://www.jetbrains.com/lp/compose-multiplatform/) is a declarative framework based on Kotlin and [Jetpack Compose](https://developer.android.com/jetpack/compose) that allows you to implement the UI -once and share it across all the platforms you target. Specifically for web platforms, Compose Multiplatform uses -Kotlin/Wasm as its compilation target. +once and share it across all the platforms you target. + +Specifically for web platforms, Compose Multiplatform uses +Kotlin/Wasm as its compilation target. Applications build with Kotlin/Wasm and Compose Multiplatform use a +Wasm-JavaScript target and run in browsers. [Explore our online demo of an application built with Compose Multiplatform and Kotlin/Wasm](https://zal.im/wasm/jetsnack/) @@ -25,31 +42,30 @@ Kotlin/Wasm as its compilation target. > {style="tip"} -[WebAssembly (Wasm)](https://webassembly.org/) is a binary instruction format for a stack-based virtual machine. This -format is platform-independent because it runs on its own virtual machine. Wasm provides Kotlin and other languages with -a compilation target to run on the web. +Additionally, you can use the most popular Kotlin libraries in Kotlin/Wasm out of the box. Like other Kotlin and Multiplatform +projects, you can include dependency declarations in the build script. For more information, +see [Adding dependencies on multiplatform libraries](multiplatform-add-dependencies.md). -Kotlin/Wasm compiles your Kotlin code into Wasm format. Using Kotlin/Wasm, you can create applications that run on -different environments and devices, which support Wasm and meet Kotlin's requirements. +Would you like to try it yourself? + +Get started with Kotlin/Wasm + +## Kotlin/Wasm and WASI + +Kotlin/Wasm benefits from [WebAssembly System Interface (WASI)](https://wasi.dev/) for server-side applications. +Applications built with Kotlin/Wasm and WASI use a Wasm-WASI target, allowing you to call the WASI API and run applications +outside the browser environment. -Kotlin/Wasm benefits from [WebAssembly System Interface (WASI)](https://wasi.dev/), which provides -a secure standard interface for running Kotlin applications compiled to WebAssembly across different environments. Kotlin/Wasm leverages WASI to abstract away platform-specific details, enabling the same Kotlin code to be executed on diverse platforms without requiring custom handling for each runtime and expanding the reach of Kotlin/Wasm beyond web applications. +WASI provides a secure standard interface for running Kotlin applications compiled to WebAssembly across different environments. + > To see Kotlin/Wasm and WASI in action with Node.js, Deno, and WasmEdge, check the [Get started with Kotlin/Wasm and WASI tutorial](wasm-wasi.md). > {style="tip"} -Additionally, you can use the most popular Kotlin libraries in Kotlin/Wasm out of the box. Like other Kotlin and Multiplatform -projects, you can include dependency declarations in the build script. For more information, -see [Adding dependencies on multiplatform libraries](multiplatform-add-dependencies.md). - -Would you like to try it yourself? - -Get started with Kotlin/Wasm - ## Kotlin/Wasm performance Although Kotlin/Wasm is still in Alpha, Compose Multiplatform running on Kotlin/Wasm already shows encouraging performance @@ -86,3 +102,9 @@ allows you to use Kotlin code from JavaScript. For more information, see [Use Ko * Learn more about Kotlin/Wasm in this [YouTube playlist](https://kotl.in/wasm-pl). * Explore the [Kotlin/Wasm examples](https://github.com/Kotlin/kotlin-wasm-examples) in our GitHub repository. + + +You can use Kotlin/Wasm on different sub-platforms such as [Compose Multiplatform](https://www.jetbrains.com/lp/compose-multiplatform/) and [WebAssembly System Interface (WASI)](https://wasi.dev/). + + + diff --git a/docs/topics/wasm-wasi.md b/docs/topics/wasm/wasm-wasi.md similarity index 87% rename from docs/topics/wasm-wasi.md rename to docs/topics/wasm/wasm-wasi.md index 7b00cd2eca7..ca291bd0313 100644 --- a/docs/topics/wasm-wasi.md +++ b/docs/topics/wasm/wasm-wasi.md @@ -6,9 +6,12 @@ > {style="note"} -This tutorial demonstrates how to run a [WASI](https://wasi.dev/) application with [Kotlin/Wasm](wasm-overview.md) in IntelliJ IDEA. -The output is a simple application that utilizes the WASI API in [Node.js](https://nodejs.org/en), [Deno](https://deno.com/), -and [WasmEdge](https://wasmedge.org/). +This tutorial demonstrates how to run a [WASI](https://wasi.dev/) application with [Kotlin/Wasm](wasm-overview.md) in IntelliJ IDEA. +You can find examples of an application running on the [Node.js](https://nodejs.org/en), [Deno](https://deno.com/), +and [WasmEdge](https://wasmedge.org/) environments. The output is a simple application that utilizes the standard WASI API. + +Currently, Kotlin/Wasm supports WASI 0.1, also known as Preview 1. +Support for WASI 0.2 will be available in the future. > This Kotlin/Wasm WASI project supports Node.js tasks (`wasmWasiNode`*) by default. > Other task variants, such as those utilizing Deno or WasmEdge, are included as custom tasks. @@ -82,9 +85,9 @@ You can also test that the Kotlin/Wasm application works correctly across variou From **kotlin-wasm-wasi-example** | **Tasks** | **verification** in the Gradle tool window, run one of the following Gradle tasks: -* **wasmWasiNodeRun** to test the application in Node.js. -* **wasmWasiDenoRun** to test the application in Deno. -* **wasmWasiWasmEdgeRun** to test the application in WasmEdge. +* **wasmWasiNodeTest** to test the application in Node.js. +* **wasmWasiDenoTest** to test the application in Deno. +* **wasmWasiWasmEdgeTest** to test the application in WasmEdge. ![Kotlin/Wasm and WASI test tasks](wasm-wasi-test-task.png){width=600}